Files
BBeOS/scripts/build-boot-image.sh
Eliott 7b53cde2ae
Some checks failed
CI / markdown-lint (push) Failing after 14s
Complete BBeOS project implementation with BlackBerry-inspired website
- Updated .gitignore with comprehensive exclusions for build artifacts, IDE files, and OS-specific files
- Created BlackBerry-inspired website with Heroicons and Gitea integration
- Added complete project structure with all 7 phases implemented
- Included kernel drivers, UI components, telephony stack, and packaging tools
- Added emulation scripts for testing and development
- Comprehensive documentation for all development phases
- Security analysis and hardware testing guides
- SDK and application framework for third-party development
2025-08-01 10:20:28 +02:00

179 lines
4.7 KiB
Bash
Executable File

#!/bin/bash
# BBeOS Boot Image Build Script
# Creates a complete boot image for BlackBerry Classic Q20
set -e
echo "Building BBeOS boot image..."
# Configuration
KERNEL_IMAGE="kernel-source/arch/arm/boot/zImage"
DTB_IMAGE="kernel-source/arch/arm/boot/dts/qcom/qcom-msm8960-blackberry-q20.dtb"
INITRAMFS="initramfs.img"
BOOT_IMAGE="bbeos-boot.img"
BOOT_IMAGE_UNPACKED="boot-unpacked"
# Check if required files exist
echo "Checking required files..."
if [ ! -f "$KERNEL_IMAGE" ]; then
echo "Error: Kernel image not found: $KERNEL_IMAGE"
echo "Please run ./scripts/build-kernel-minimal.sh first"
exit 1
fi
if [ ! -f "$DTB_IMAGE" ]; then
echo "Error: Device tree blob not found: $DTB_IMAGE"
echo "Please run ./scripts/build-kernel-minimal.sh first"
exit 1
fi
if [ ! -f "$INITRAMFS" ]; then
echo "Error: Initramfs not found: $INITRAMFS"
echo "Please run ./scripts/build-rootfs.sh first"
exit 1
fi
echo "All required files found!"
# Create boot image directory structure
echo "Creating boot image structure..."
rm -rf $BOOT_IMAGE_UNPACKED
mkdir -p $BOOT_IMAGE_UNPACKED
# Copy files to boot image directory
cp $KERNEL_IMAGE $BOOT_IMAGE_UNPACKED/zImage
cp $DTB_IMAGE $BOOT_IMAGE_UNPACKED/dtb
cp $INITRAMFS $BOOT_IMAGE_UNPACKED/initramfs.img
# Create boot image using mkbootimg (if available)
if command -v mkbootimg &> /dev/null; then
echo "Using mkbootimg to create boot image..."
mkbootimg \
--kernel $BOOT_IMAGE_UNPACKED/zImage \
--dtb $BOOT_IMAGE_UNPACKED/dtb \
--ramdisk $BOOT_IMAGE_UNPACKED/initramfs.img \
--cmdline "console=ttyMSM0,115200 root=/dev/ram0 rw rootwait" \
--base 0x80200000 \
--pagesize 2048 \
--ramdisk_offset 0x02000000 \
--tags_offset 0x01e00000 \
--output $BOOT_IMAGE
else
echo "mkbootimg not found, creating simple concatenated image..."
echo "Note: This may not work with all bootloaders"
# Create a simple concatenated image
cat $BOOT_IMAGE_UNPACKED/zImage $BOOT_IMAGE_UNPACKED/dtb > $BOOT_IMAGE.tmp
# Add initramfs if it exists
if [ -f $BOOT_IMAGE_UNPACKED/initramfs.img ]; then
cat $BOOT_IMAGE.tmp $BOOT_IMAGE_UNPACKED/initramfs.img > $BOOT_IMAGE
rm $BOOT_IMAGE.tmp
else
mv $BOOT_IMAGE.tmp $BOOT_IMAGE
fi
fi
# Create a simple boot script for testing
echo "Creating boot script for testing..."
cat > $BOOT_IMAGE_UNPACKED/boot.scr << 'EOF'
# BBeOS Boot Script
# For testing with QEMU or other bootloaders
# Load kernel
fatload mmc 0:1 0x80200000 zImage
# Load device tree
fatload mmc 0:1 0x82000000 dtb
# Load initramfs
fatload mmc 0:1 0x83000000 initramfs.img
# Boot kernel
bootz 0x80200000 0x83000000 0x82000000
EOF
# Create a QEMU test script
echo "Creating QEMU test script..."
cat > test-qemu.sh << 'EOF'
#!/bin/bash
# QEMU Test Script for BBeOS
# Tests the kernel and initramfs in emulation
echo "Testing BBeOS in QEMU..."
# Check if QEMU is available
if ! command -v qemu-system-arm &> /dev/null; then
echo "Error: qemu-system-arm not found"
echo "Please install QEMU: sudo apt install qemu-system-arm"
exit 1
fi
# Run QEMU with our kernel and initramfs
qemu-system-arm \
-M vexpress-a9 \
-cpu cortex-a9 \
-m 512M \
-kernel kernel-source/arch/arm/boot/zImage \
-dtb kernel-source/arch/arm/boot/dts/qcom/qcom-msm8960-blackberry-q20.dtb \
-initrd initramfs.img \
-append "console=ttyAMA0,115200 root=/dev/ram0 rw rootwait" \
-nographic \
-serial mon:stdio
echo "QEMU test complete"
EOF
chmod +x test-qemu.sh
# Create a fastboot flash script
echo "Creating fastboot flash script..."
cat > flash-boot.sh << 'EOF'
#!/bin/bash
# Fastboot Flash Script for BBeOS
# Flashes the boot image to device via fastboot
echo "Flashing BBeOS boot image..."
# Check if fastboot is available
if ! command -v fastboot &> /dev/null; then
echo "Error: fastboot not found"
echo "Please install Android tools: sudo apt install android-tools-fastboot"
exit 1
fi
# Check if device is connected
if ! fastboot devices | grep -q .; then
echo "Error: No fastboot device found"
echo "Please connect device in fastboot mode"
exit 1
fi
# Flash boot image
echo "Flashing boot image..."
fastboot flash boot bbeos-boot.img
# Reboot device
echo "Rebooting device..."
fastboot reboot
echo "Flash complete!"
EOF
chmod +x flash-boot.sh
echo "Boot image build complete!"
echo ""
echo "Files created:"
echo " - $BOOT_IMAGE (boot image)"
echo " - $BOOT_IMAGE_UNPACKED/ (unpacked boot files)"
echo " - test-qemu.sh (QEMU test script)"
echo " - flash-boot.sh (fastboot flash script)"
echo ""
echo "To test in QEMU: ./test-qemu.sh"
echo "To flash to device: ./flash-boot.sh"
echo ""
echo "Boot image size: $(ls -lh $BOOT_IMAGE | awk '{print $5}')"