Expose boot eMMC partitions and mark them as bootable

Can be used to install for example Tow-Boot from a host PC
This commit is contained in:
Bart Ribbers 2022-03-09 13:43:23 +01:00
parent 8f296e08a4
commit 2ae4b2e471
No known key found for this signature in database
GPG Key ID: 0BF4C1B5988C50D8
5 changed files with 40 additions and 2 deletions

2
.gitignore vendored
View File

@ -1,6 +1,7 @@
/*.img /*.img
/*.apk /*.apk
/initramfs/bin/busybox /initramfs/bin/busybox
/initramfs/bin/mmc
/initramfs-* /initramfs-*
/build /build
/dtbs /dtbs
@ -10,6 +11,7 @@
/src/linux-librem5 /src/linux-librem5
/src/linux-sdm845 /src/linux-sdm845
/src/busybox /src/busybox
/src/mmc-utils
/src/u-boot /src/u-boot
/src/u-boot-pocketpc /src/u-boot-pocketpc
/src/u-boot-librem5 /src/u-boot-librem5

View File

@ -1,3 +1,4 @@
CC = aarch64-linux-gnu-gcc
CROSS_FLAGS = ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CROSS_FLAGS = ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
CROSS_FLAGS_BOOT = CROSS_COMPILE=aarch64-linux-gnu- CROSS_FLAGS_BOOT = CROSS_COMPILE=aarch64-linux-gnu-
@ -120,11 +121,17 @@ initramfs/bin/busybox: src/busybox src/busybox_config
@$(MAKE) -C src/busybox O=../../build/busybox $(CROSS_FLAGS) @$(MAKE) -C src/busybox O=../../build/busybox $(CROSS_FLAGS)
@cp build/busybox/busybox initramfs/bin/busybox @cp build/busybox/busybox initramfs/bin/busybox
initramfs/bin/mmc-utils: src/mmc-utils
@echo "MAKE $@"
@mkdir -p build/mmc-utils
@$(MAKE) -C src/mmc-utils O=../../build/mmc-utils CFLAGS="-Wno-error -static" CC=$(CC)
@cp src/mmc-utils/mmc initramfs/bin/mmc
splash/%.ppm.gz: splash/%.ppm splash/%.ppm.gz: splash/%.ppm
@echo "GZ $@" @echo "GZ $@"
@gzip < $< > $@ @gzip < $< > $@
initramfs-%.cpio: initramfs/bin/busybox initramfs/init initramfs/init_functions.sh splash/%.ppm.gz splash/%-error.ppm.gz initramfs-%.cpio: initramfs/bin/busybox initramfs/bin/mmc-utils initramfs/init initramfs/init_functions.sh splash/%.ppm.gz splash/%-error.ppm.gz
@echo "CPIO $@" @echo "CPIO $@"
@rm -rf initramfs-$* @rm -rf initramfs-$*
@cp -r initramfs initramfs-$* @cp -r initramfs initramfs-$*
@ -309,6 +316,12 @@ src/busybox:
@wget https://www.busybox.net/downloads/busybox-1.32.0.tar.bz2 @wget https://www.busybox.net/downloads/busybox-1.32.0.tar.bz2
@tar -xf busybox-1.32.0.tar.bz2 --strip-components 1 -C src/busybox @tar -xf busybox-1.32.0.tar.bz2 --strip-components 1 -C src/busybox
src/mmc-utils:
@echo "WGET mmc-utils"
@mkdir src/mmc-utils
@wget https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/snapshot/mmc-utils-0eea71e4f22a837ed59e607743767df2d038825e.tar.gz
@tar -xf mmc-utils-0eea71e4f22a837ed59e607743767df2d038825e.tar.gz --strip-components 1 -C src/mmc-utils
.PHONY: clean cleanfast purism-librem5 .PHONY: clean cleanfast purism-librem5
purism-librem5: initramfs-purism-librem5.gz kernel-librem5.gz u-boot-librem5.bin src/purism-librem5.txt dtbs/librem5/imx8mq-librem5-r2.dtb purism-librem5: initramfs-purism-librem5.gz kernel-librem5.gz u-boot-librem5.bin src/purism-librem5.txt dtbs/librem5/imx8mq-librem5-r2.dtb

View File

@ -46,6 +46,10 @@ The dependencies are:
- aarch64-linux-gnu- toolchain - aarch64-linux-gnu- toolchain
- u-boot tools - u-boot tools
- mtools - mtools
- swig
- dtc
- cpio
- bc
Additional dependencies for the Purism Librem 5: Additional dependencies for the Purism Librem 5:
- arm-none-eabi- toolchain - arm-none-eabi- toolchain
@ -72,5 +76,6 @@ Generates an image for every supported platform in parallel
- [Busybox](https://busybox.net) - which is [GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html). - [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). - [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). - [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) - [U-Boot](https://github.com/u-boot/u-boot) - which has [multiple licenses](https://github.com/u-boot/u-boot/tree/master/Licenses).
- [mmc-utils](https://www.kernel.org/doc/html/latest/driver-api/mmc/mmc-tools.html) - which is [GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html).

View File

@ -58,10 +58,27 @@ setup_usb_configfs() {
echo $EMMC > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.0/file echo $EMMC > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.0/file
echo $SD > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.1/file echo $SD > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.1/file
if [ -n "$EMMC_BOOT" ]; then
echo "$EMMC_BOOT" > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.2/file
fi
# Rename the mass storage device # Rename the mass storage device
echo "JumpDrive eMMC" > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.0/inquiry_string echo "JumpDrive eMMC" > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.0/inquiry_string
echo "JumpDrive microSD" > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.1/inquiry_string echo "JumpDrive microSD" > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.1/inquiry_string
if [ -n "$EMMC_BOOT" ]; then
echo "JumpDrive eMMC Boot" > $CONFIGFS/g1/functions/"$usb_mass_storage_function"/lun.2/inquiry_string
# Make sure the boot partitions are rw
for f in /sys/block/mmcblk*boot*/force_ro; do
echo 0 > "$f"
done
# Mark the boot partitions as bootable
mmc bootbus set single_hs x1 x4 "$EMMC_BOOT"
mmc bootpart enable 1 1 "$EMMC_BOOT"
fi
# Link the rndis/mass_storage instance to the configuration # Link the rndis/mass_storage instance to the configuration
ln -s $CONFIGFS/g1/functions/"$usb_rndis_function" $CONFIGFS/g1/configs/c.1 \ ln -s $CONFIGFS/g1/functions/"$usb_rndis_function" $CONFIGFS/g1/configs/c.1 \
|| echo " Couldn't symlink $usb_rndis_function" || echo " Couldn't symlink $usb_rndis_function"

View File

@ -2,6 +2,7 @@ PLATFORM=pine64-pinephone
MANUFACTURER=Pine64 MANUFACTURER=Pine64
PRODUCT=PinePhone PRODUCT=PinePhone
EMMC=/dev/mmcblk2 EMMC=/dev/mmcblk2
EMMC_BOOT=/dev/mmcblk2boot1
SD=/dev/mmcblk0 SD=/dev/mmcblk0
LED=red\:indicator LED=red\:indicator
TRIGGER=mmc2 TRIGGER=mmc2