-======== Build busybox 1.32 for aarch64 ======== \r
-\r
-ARCH=arm64 CROSS_COMPILE=aarch64-linux- make defconfig\r
-ARCH=arm64 CROSS_COMPILE=aarch64-linux- make menuconfig \r
-----> enable static build\r
-----> enable ar\r
-----> enable inotifyd\r
-\r
-\r
+======== How to build ash/hexdump/xzcat for aarch64 ======== \r
+#How to get ash.config/hexdump.cofig/xzcat.config\r
+#ARCH=arm64 CROSS_COMPILE=aarch64-linux- make allnoconfig\r
+#ARCH=arm64 CROSS_COMPILE=aarch64-linux- make menuconfig \r
+#----> enable static build\r
+#----> enable xzcat\r
+#get aarch64_xzcat.config\r
+\r
+tar xf busybox-1.32.0.tar.bz2\r
+cd busybox-1.32.0\r
+copy aarch64_xzcat.config as .config\r
ARCH=arm64 CROSS_COMPILE=aarch64-linux- make \r
+rename ./busybox to xzcat\r
\r
\r
\r
+======== How to build ash/hexdump/xzcat for x86_64 ==========\r
+#How to get ash.config/hexdump.cofig/xzcat.config\r
+#make allnoconfig\r
+#make menuconfig \r
+#----> enable static build\r
+#----> enable xzcat\r
+#get x86_64_xzcat.config\r
\r
-ARCH=arm64 CROSS_COMPILE=aarch64-linux- make allnoconfig \r
\r
+tar xf busybox-1.32.0.tar.bz2\r
+cd busybox-1.32.0\r
+copy x86_64_xzcat.config as .config\r
+modify Makefile\r
+CC = gcc -specs "/usr/local/musl/lib/musl-gcc.specs"\r
+MODFLAGS = -DMODULE -specs "/usr/local/musl/lib/musl-gcc.specs"\r
+make\r
+rename ./busybox to xzcat\r
\r
-======== use mini-native-x86_64 uclibc to build ash/hexdump/busybox for x86_64 ==========\r
\r
\r
DSTDIR=../../IMG/cpio/ventoy/busybox
-rm -f vtchmod32 vtchmod64 vtchmodaa64
+rm -f vtchmod32 vtchmod64 vtchmod64_musl vtchmodaa64
rm -f $DSTDIR/vtchmod32 $DSTDIR/vtchmod64 $DSTDIR/vtchmodaa64
/opt/diet32/bin/diet gcc -Os -m32 vtchmod.c -o vtchmod32
aarch64-linux-gcc -Os -static vtchmod.c -o vtchmodaa64
aarch64-linux-strip --strip-all vtchmodaa64
+gcc -specs "/usr/local/musl/lib/musl-gcc.specs" -Os -static vtchmod.c -o vtchmod64_musl
+strip --strip-all vtchmod64_musl
chmod 777 vtchmod32
chmod 777 vtchmod64
chmod 777 vtchmodaa64
+chmod 777 vtchmod64_musl
cp -a vtchmod32 $DSTDIR/
cp -a vtchmod64 $DSTDIR/
cp -a vtchmodaa64 $DSTDIR/
+cp -a vtchmod64_musl $DSTDIR/
\r
\r
======================== Build for 64bit dmsetup =========================\r
-https://www.uclibc.org/downloads/binaries/0.9.30.1/mini-native-x86_64.tar.bz2\r
1. extract device mapper source code\r
-2. extract mini-native-x86_64.tar.bz2\r
-3. chroot to mini-native-x86_64\r
-3. ./configure --disable-nls --disable-selinux --disable-shared --enable-static_link\r
+2. ./configure --disable-nls --disable-selinux --disable-shared --enable-static_link CC='gcc -specs /usr/local/musl/lib/musl-gcc.specs'\r
+3. touch include/linux/limits.h include/linux/types.h \r
+ echo '#include <sys/mount.h>' > include/linux/fs.h\r
4. make\r
-5. strip dmsetup/dmsetup.static\r
+5. strip --strip-all dmsetup/dmsetup.static\r
6. get dmsetup/dmsetup.static as the dmsetup64 binary file\r
\r
\r
-\r
-\r
======================== Build for arm64 dmsetup =========================\r
-https://www.uclibc.org/downloads/binaries/0.9.30.1/mini-native-x86_64.tar.bz2\r
1. extract device mapper source code\r
2. ./configure CC=aarch64-linux-gcc --target=arm --host=x86_64-linux-gnu --disable-nls --disable-selinux --disable-shared --enable-static_link\r
3. modify include/configure.h file\r
2.2 Download third-part source code\r
\r
https://www.fefe.de/dietlibc/dietlibc-0.34.tar.xz ===> /home/Ventoy-master/DOC/dietlibc-0.34.tar.xz\r
+ https://musl.libc.org/releases/musl-1.2.1.tar.gz ===> /home/Ventoy-master/DOC/musl-1.2.1.tar.gz\r
https://ftp.gnu.org/gnu/grub/grub-2.04.tar.xz ===> /home/Ventoy-master/GRUB2/grub-2.04.tar.xz\r
https://codeload.github.com/tianocore/edk2/zip/edk2-stable201911 ===> /home/Ventoy-master/EDK2/edk2-edk2-stable201911.zip\r
https://codeload.github.com/relan/exfat/zip/v1.3.0 ===> /home/Ventoy-master/ExFAT/exfat-1.3.0.zip\r
https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz ===> /opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz\r
https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--uclibc--stable-2020.08-1.tar.bz2 ===> /opt/aarch64--uclibc--stable-2020.08-1.tar.bz2\r
\r
+2.3 Prepare third-part tools\r
+ cd /home/Ventoy-master/DOC/\r
+ tar xf musl-1.2.1.tar.gz\r
+ cd musl-1.2.1\r
+ ./configure && make install\r
+\r
+ tar xf /opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz -C /opt\r
+ tar xf /opt/aarch64--uclibc--stable-2020.08-1.tar.bz2 -C /opt\r
+\r
+2.4 Set PATH envrioment\r
+ export PATH=$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin:/opt/aarch64--uclibc--stable-2020.08-1/bin\r
+ better to add this line to /root/.bashrc and relogin as root\r
+\r
\r
==========================================\r
3. All in one script\r
int ventoy_check_device(grub_device_t dev)
{
+ int workaround = 0;
grub_file_t file;
grub_uint64_t offset;
char devname[64];
0 == ventoy_check_file_exist("(%s,2)/grub/localboot.cfg", dev->disk->name) ||
0 == ventoy_check_file_exist("(%s,2)/tool/mount.exfat-fuse_aarch64", dev->disk->name))
{
- return ventoy_check_device_result(2 | 0x1000);
+ #ifndef GRUB_MACHINE_EFI
+ if (0 == ventoy_check_file_exist("(ventoydisk)/ventoy/ventoy.cpio", dev->disk->name) ||
+ 0 == ventoy_check_file_exist("(ventoydisk)/grub/localboot.cfg", dev->disk->name) ||
+ 0 == ventoy_check_file_exist("(ventoydisk)/tool/mount.exfat-fuse_aarch64", dev->disk->name))
+ {
+ return ventoy_check_device_result(2 | 0x1000);
+ }
+ else
+ {
+ workaround = 1;
+ }
+ #endif
}
/* We must have partition 2 */
- file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(%s,2)/ventoy/ventoy.cpio", dev->disk->name);
+ if (workaround)
+ {
+ file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", "(ventoydisk)/ventoy/ventoy.cpio");
+ }
+ else
+ {
+ file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(%s,2)/ventoy/ventoy.cpio", dev->disk->name);
+ }
if (!file)
{
return ventoy_check_device_result(3 | 0x1000);
return ventoy_check_device_result(5);
}
- offset = partition->start + partition->len;
- partition = file->device->disk->partition;
- if ((partition->number != 1) || (partition->len != 65536) || (offset != partition->start))
+ if (workaround)
{
- grub_file_close(file);
- return ventoy_check_device_result(6);
+ ventoy_part_table *PartTbl = g_ventoy_part_info->MBR.PartTbl;
+ if (PartTbl[1].StartSectorId != PartTbl[0].StartSectorId + PartTbl[0].SectorCount ||
+ PartTbl[1].SectorCount != 65536)
+ {
+ grub_file_close(file);
+ return ventoy_check_device_result(6);
+ }
}
- grub_file_close(file);
-
- grub_snprintf(devname, sizeof(devname), "%s,2", dev->disk->name);
- dev2 = grub_device_open(devname);
- if (!dev2)
+ else
{
- return ventoy_check_device_result(7);
+ offset = partition->start + partition->len;
+ partition = file->device->disk->partition;
+ if ((partition->number != 1) || (partition->len != 65536) || (offset != partition->start))
+ {
+ grub_file_close(file);
+ return ventoy_check_device_result(7);
+ }
}
- fs = grub_fs_probe(dev2);
- if (!fs)
- {
- grub_device_close(dev2);
- return ventoy_check_device_result(8);
- }
+ grub_file_close(file);
- fs->fs_label(dev2, &label);
- if ((!label) || grub_strncmp("VTOYEFI", label, 7))
+ if (workaround == 0)
{
- grub_device_close(dev2);
- return ventoy_check_device_result(9);
- }
+ grub_snprintf(devname, sizeof(devname), "%s,2", dev->disk->name);
+ dev2 = grub_device_open(devname);
+ if (!dev2)
+ {
+ return ventoy_check_device_result(8);
+ }
- grub_device_close(dev2);
+ fs = grub_fs_probe(dev2);
+ if (!fs)
+ {
+ grub_device_close(dev2);
+ return ventoy_check_device_result(9);
+ }
+
+ fs->fs_label(dev2, &label);
+ if ((!label) || grub_strncmp("VTOYEFI", label, 7))
+ {
+ grub_device_close(dev2);
+ return ventoy_check_device_result(10);
+ }
+
+ grub_device_close(dev2);
+ }
+
return ventoy_check_device_result(0);
}
if [ -s $BUSYBOX_PATH/busybox ]; then
$BUSYBOX_PATH/vtchmod64 $BUSYBOX_PATH/busybox
else
- $BUSYBOX_PATH/xzminidec64_uclibc < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
- $BUSYBOX_PATH/vtchmod64_uclibc $BUSYBOX_PATH/busybox
+ $BUSYBOX_PATH/xzminidec64_musl < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
+ $BUSYBOX_PATH/vtchmod64_musl $BUSYBOX_PATH/busybox
fi
fi
else
--- /dev/null
+#
+# Makefile
+#
+# Author: Lasse Collin <lasse.collin@tukaani.org>
+#
+# This file has been put into the public domain.
+# You can do whatever you want with this file.
+#
+
+CC = gcc -specs "/usr/local/musl/lib/musl-gcc.specs" -Os -static -std=gnu89
+BCJ_CPPFLAGS = -DXZ_DEC_X86 -DXZ_DEC_POWERPC -DXZ_DEC_IA64 \
+ -DXZ_DEC_ARM -DXZ_DEC_ARMTHUMB -DXZ_DEC_SPARC
+CPPFLAGS = -DXZ_USE_CRC64 -DXZ_DEC_ANY_CHECK
+CFLAGS = -ggdb3 -O2 -pedantic -Wall -Wextra
+RM = rm -f
+VPATH = ../linux/include/linux ../linux/lib/xz
+COMMON_SRCS = xz_crc32.c xz_crc64.c xz_dec_stream.c xz_dec_lzma2.c xz_dec_bcj.c
+COMMON_OBJS = $(COMMON_SRCS:.c=.o)
+XZMINIDEC_OBJS = xzminidec.o
+BYTETEST_OBJS = bytetest.o
+BUFTEST_OBJS = buftest.o
+BOOTTEST_OBJS = boottest.o
+XZ_HEADERS = xz.h xz_private.h xz_stream.h xz_lzma2.h xz_config.h
+PROGRAMS = xzminidec bytetest buftest boottest
+
+ALL_CPPFLAGS = -I../linux/include/linux -I. $(BCJ_CPPFLAGS) $(CPPFLAGS)
+
+all: $(PROGRAMS)
+
+%.o: %.c $(XZ_HEADERS)
+ $(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
+
+xzminidec: $(COMMON_OBJS) $(XZMINIDEC_OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(XZMINIDEC_OBJS)
+
+bytetest: $(COMMON_OBJS) $(BYTETEST_OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BYTETEST_OBJS)
+
+buftest: $(COMMON_OBJS) $(BUFTEST_OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BUFTEST_OBJS)
+
+boottest: $(BOOTTEST_OBJS) $(COMMON_SRCS)
+ $(CC) $(ALL_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(BOOTTEST_OBJS)
+
+.PHONY: clean
+clean:
+ -$(RM) $(COMMON_OBJS) $(XZMINIDEC_OBJS) $(BUFTEST_OBJS) \
+ $(BOOTTEST_OBJS) $(PROGRAMS)
--- /dev/null
+#
+# Makefile
+#
+# Author: Lasse Collin <lasse.collin@tukaani.org>
+#
+# This file has been put into the public domain.
+# You can do whatever you want with this file.
+#
+
+CC = /opt/aarch64--uclibc--stable-2020.08-1/bin/aarch64-linux-gcc -Os -static -std=gnu89
+BCJ_CPPFLAGS = -DXZ_DEC_X86 -DXZ_DEC_POWERPC -DXZ_DEC_IA64 \
+ -DXZ_DEC_ARM -DXZ_DEC_ARMTHUMB -DXZ_DEC_SPARC
+CPPFLAGS = -DXZ_USE_CRC64 -DXZ_DEC_ANY_CHECK
+CFLAGS = -ggdb3 -O2 -pedantic -Wall -Wextra
+RM = rm -f
+VPATH = ../linux/include/linux ../linux/lib/xz
+COMMON_SRCS = xz_crc32.c xz_crc64.c xz_dec_stream.c xz_dec_lzma2.c xz_dec_bcj.c
+COMMON_OBJS = $(COMMON_SRCS:.c=.o)
+XZMINIDEC_OBJS = xzminidec.o
+BYTETEST_OBJS = bytetest.o
+BUFTEST_OBJS = buftest.o
+BOOTTEST_OBJS = boottest.o
+XZ_HEADERS = xz.h xz_private.h xz_stream.h xz_lzma2.h xz_config.h
+PROGRAMS = xzminidec bytetest buftest boottest
+
+ALL_CPPFLAGS = -I../linux/include/linux -I. $(BCJ_CPPFLAGS) $(CPPFLAGS)
+
+all: $(PROGRAMS)
+
+%.o: %.c $(XZ_HEADERS)
+ $(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
+
+xzminidec: $(COMMON_OBJS) $(XZMINIDEC_OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(XZMINIDEC_OBJS)
+
+bytetest: $(COMMON_OBJS) $(BYTETEST_OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BYTETEST_OBJS)
+
+buftest: $(COMMON_OBJS) $(BUFTEST_OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BUFTEST_OBJS)
+
+boottest: $(BOOTTEST_OBJS) $(COMMON_SRCS)
+ $(CC) $(ALL_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(BOOTTEST_OBJS)
+
+.PHONY: clean
+clean:
+ -$(RM) $(COMMON_OBJS) $(XZMINIDEC_OBJS) $(BUFTEST_OBJS) \
+ $(BOOTTEST_OBJS) $(PROGRAMS)