sipeed / LonganPi-3H-SDK

LonganPi 3H SDK
GNU General Public License v3.0
28 stars 14 forks source link

Questions about the Debian version #49

Closed windskyxb closed 4 months ago

windskyxb commented 4 months ago

Can I provide an image of Bookworm or Bullseye? Docker cannot be installed on Trixie

metrolan commented 4 months ago

Maybe I can help you. I've just made a image witch stable version. To send you a img is not a good way due to securtity reasons, you will want to create the image yourself. I can send the .sh files I used to do that but I don't manage well github to send pull requests. I can put here the scripts, if there is no problems to do that.

metrolan commented 4 months ago

I used mkatf.sh, mklinux.sh and mkuboot.sh as is, no modification here. You must follow the steps in Initial steps

But for building rootfs and image you must use my files, both are in following posts.

metrolan commented 4 months ago

for the rootfs use this code. It is mandatory to name it mkrootfs_debian_stable_cli.sh or edit mkimage_deb_stable.sh if you use other name.

#!/usr/bin/env bash

if [ -z "$MMDEBSTRAP" ]
then
    MMDEBSTRAP=mmdebstrap
fi

mkdir build

set -eux

genrootfs() {
echo "
deb https://mirrors.bfsu.edu.cn/debian/ stable main contrib non-free non-free-firmware
deb https://mirrors.bfsu.edu.cn/debian/ stable-updates main contrib non-free non-free-firmware
deb https://mirrors.bfsu.edu.cn/debian/ stable-backports main contrib non-free non-free-firmware
deb https://mirrors.bfsu.edu.cn/debian-security/ stable-security main contrib non-free non-free-firmware
" | $MMDEBSTRAP --aptopt='Dir::Etc::Trusted "/usr/share/keyrings/debian-archive-keyring.gpg"' --architectures=arm64 -v -d \
        --include="ca-certificates locales dosfstools binutils file \
        tree sudo bash-completion memtester openssh-server wireless-regdb \
        wpasupplicant systemd-timesyncd usbutils parted systemd-sysv \
        iperf3 stress-ng avahi-daemon tmux screen i2c-tools net-tools \
        ethtool ckermit lrzsz minicom picocom btop neofetch iotop htop \
        bmon e2fsprogs nvi tcpdump alsa-utils squashfs-tools evtest \
        bluez bluez-hcidump bluez-tools btscanner bluez-alsa-utils \
        device-tree-compiler debian-archive-keyring linux-cpupower \
        pulseaudio-module-bluetooth blueman network-manager network-manager-config-connectivity-debian" > ./build/rootfs_debian_stable_cli.tar
}

genrootfs   # if you want skip debian rootfs build, please comment this line
cd overlay
for i in *
do
tar --append --file=../build/rootfs_debian_stable_cli.tar $i
done
cd ..
metrolan commented 4 months ago

then, you will run mkimage_deb_stable.sh, this is the code:


#!/bin/bash

# Set up variables
BUILD_DIR="./build"
CREATE_IMG="sdcard.img"

export DATE=$(date +"%Y%m%d")
CREATE_IMG="LPI3H_${DATE}.img"

BOOT_SIZE="64M"
ROOTFS_SIZE="2G"
IMAGE_SIZE="3072"
BOOT_PARTITION="${CREATE_IMG}1"
ROOTFS_PARTITION="${CREATE_IMG}2"

# Check if the script is run as root
if [ "$(id -u)" -ne 0 ]; then
    echo "This script must be run as root. Please use 'sudo' or log in as root."
    exit 1
fi

# Function to convert size to megabytes
convert_to_mb() {
    local size=$1
    local number=${size%[GM]}
    local unit=${size: -1}

    case "$unit" in
        G) echo $((number * 1024)) ;;
        M) echo $number ;;
        *) echo "Invalid size: $size" >&2; exit 1 ;;
    esac
}

# Create an empty image file
# Convert sizes to megabytes
BOOT_SIZE_MB=$(convert_to_mb $BOOT_SIZE)
ROOTFS_SIZE_MB=$(convert_to_mb $ROOTFS_SIZE)
# Calculate total size in MB for dd command
TOTAL_SIZE_MB=$((BOOT_SIZE_MB + ROOTFS_SIZE_MB))

dd if=/dev/zero of="$CREATE_IMG" bs=1M count=$IMAGE_SIZE

# Create partitions using sfdisk (script friendly fdisk)
# the 2048 is the allocation so we don't ovewrite uboot
{
echo label: dos
echo start=2048, size=+${BOOT_SIZE_MB}M, type=c, bootable
echo type=83
} | sudo sfdisk "$CREATE_IMG"

# Associate loop devices
LOOP_DEV=$(losetup -fP --show "$CREATE_IMG")
if [ -z "$LOOP_DEV" ]; then
    echo "Failed to associate loop device."
    exit 1
fi

# Format partitions
echo "Formatting partitions..."

sudo mkfs.vfat -F 32 -n "boot" "${LOOP_DEV}p1" || { echo "Failed to format boot partition."; exit 1; }
sudo mkfs.ext4 -t ext4 -F -L "rootfs" "${LOOP_DEV}p2" || { echo "Failed to format rootfs partition."; exit 1; }

echo "flash uboot"
sudo dd if=$BUILD_DIR/u-boot-sunxi-with-spl.bin of="${LOOP_DEV}" bs=1k seek=8 conv=fsync

# Mount partitions
echo "Mounting partitions..."
mkdir -p /tmp/{boot,rootfs}
sudo mount "${LOOP_DEV}p1" /tmp/boot || { echo "Failed to mount boot partition."; exit 1; }
sudo mount "${LOOP_DEV}p2" /tmp/rootfs || { echo "Failed to mount rootfs partition."; exit 1; }

# Proceed with partitioning, formatting, and other steps...
# Copy kernel and device tree files
# -L to copy symlinks, since vfat filesystems don't support those!
sudo cp -Lr ./overlay/boot/. /tmp/boot

# Extract root filesystem
echo "Extracting root filesystem..."
sudo tar -xpf $BUILD_DIR/rootfs_debian_stable_cli.tar -C /tmp/rootfs

# Unmount partitions
sudo umount /tmp/{boot,rootfs}

# Detach loop device
sudo losetup -d "$LOOP_DEV"

echo "finished - copy $CREATE_IMG"

# End of script

Hopefully this can help you. This also solve another problem in original mkimage.sh script about the name of rootfs.tar.

windskyxb commented 4 months ago

I used mkatf.sh, mklinux.sh and mkuboot.sh as is, no modification here. You must follow the steps in But for building rootfs and image you must use my files, both are in following posts.

thank you very much!

metrolan commented 4 months ago

I used mkatf.sh, mklinux.sh and mkuboot.sh as is, no modification here. You must follow the steps in But for building rootfs and image you must use my files, both are in following posts.

thank you very much!

Hi Have you have succeed with starting docker? I have not, because iptables complaint abuot accessing tables.

windskyxb commented 4 months ago

I used mkatf.sh, mklinux.sh and mkuboot.sh as is, no modification here. You must follow the steps in But for building rootfs and image you must use my files, both are in following posts.

thank you very much!

Hi Have you have succeed with starting docker? I have not, because iptables complaint abuot accessing tables.

If you want to run Docker, in addition to changing Rootfs, you also need to modify Kernel, open the dependencies needed by Docker and compile Kernel

metrolan commented 4 months ago

I used mkatf.sh, mklinux.sh and mkuboot.sh as is, no modification here. You must follow the steps in But for building rootfs and image you must use my files, both are in following posts.

thank you very much!

Hi Have you have succeed with starting docker? I have not, because iptables complaint abuot accessing tables.

If you want to run Docker, in addition to changing Rootfs, you also need to modify Kernel, open the dependencies needed by Docker and compile Kernel

Thankyou,

Where can I find those dependencies?, I've been looking around but I don't see nothing wrong in longanpi_3h_defconfig Can you tell which changes must be done?

windskyxb commented 4 months ago

I used mkatf.sh, mklinux.sh and mkuboot.sh as is, no modification here. You must follow the steps in But for building rootfs and image you must use my files, both are in following posts.

thank you very much!

Hi Have you have succeed with starting docker? I have not, because iptables complaint abuot accessing tables.

If you want to run Docker, in addition to changing Rootfs, you also need to modify Kernel, open the dependencies needed by Docker and compile Kernel

Thankyou,

Where can I find those dependencies?, I've been looking around but I don't see nothing wrong in longanpi_3h_defconfig Can you tell which changes must be done?

https://github.com/sipeed/LonganPi-3H-SDK/issues/50#issuecomment-2074763003

metrolan commented 4 months ago

I used mkatf.sh, mklinux.sh and mkuboot.sh as is, no modification here. You must follow the steps in But for building rootfs and image you must use my files, both are in following posts.

thank you very much!

Hi Have you have succeed with starting docker? I have not, because iptables complaint abuot accessing tables.

If you want to run Docker, in addition to changing Rootfs, you also need to modify Kernel, open the dependencies needed by Docker and compile Kernel

Thankyou, Where can I find those dependencies?, I've been looking around but I don't see nothing wrong in longanpi_3h_defconfig Can you tell which changes must be done?

#50 (comment)

Thanks, I supposed it was already merged in the main branch. I'll give a try.