embeded/orange pi2023. 7. 6. 11:10

sd 카드 내용 전체를 eMMC로 복사하니 된다. 이게 머야(!)

[링크 : https://www.reddit.com/r/OrangePI/comments/vpzhjw/how_can_i_put_a_os_in_the_emmc_3_lts/]

 

+

안되잖아?!

$ wget https://raw.githubusercontent.com/loboris/OrangePi-BuildLinux/master/install_to_emmc
$ chmod +x install_to_emmc
$ sudo ./install_to_emmc
Thu 06 Jul 2023 02:34:17 AM UTC
===============================
Installing Linux system to emmc
===============================

Error: boot0_OPI.fex not found.

 

+

차라리 armbian 기반에 해야하려나?

[링크 : https://forum.libreelec.tv/thread/25388-orange-pi-3-emmc-install/]

 

-------

 

사용자 메뉴얼에 보면 install_to_emmc 치면 설치된다는데

정작 Orangepi3_2.1.0_ubuntu_focal_desktop_linux5.4.65.img 이미지를 이용해서 부팅해보면

해당 스크립트가 없다. debian도 아니고 ubuntu focal 이면 20.04인데

자기들이 릴리즈 하고 어디서 받으라는 말도 없는건 도대체 멀까?

3. Program Linux system into EMMC Flash chip through script
If you purchased the Orange Pi 3 development board with EMMC Flash chip, after booting the Linux system through the TF card, you can also burn the Linux system into EMMC Flash through the install_to_emmc script.
Enter the install_to_emmc command in the Linux terminal, and then enter y as prompted, and the Linux system will automatically be burned into EMMC Flash. After the programming is complete, turn off the power, remove the TF card, and then power on the Linux system in EMMC Flash automatically.

root@OrangePi:~# install_to_emmc
WARNING: EMMC WILL BE ERASED !, Continue (y/N)? y
Erasing EMMC ...
Creating new filesystem on EMMC ...
New filesystem created on /dev/mmcblk0.
Partitioning EMMC ...
Creating boot & linux partitions
OK.
Formating fat partition ...
fat partition formated.
Formating linux partition (ext4), please wait ...
linux partition formated.
Instaling u-boot to EMMC ...
Mounting EMMC partitions...
FAT partitions mounted to /tmp/_fatdir
linux partition mounted to /tmp/_extdir
Copying file system to EMMC ...
Creating "fstab"
*******************************
Linux system installed to EMMC.
*******************************

 

인터넷 찾아보니

아래 스크립트가 나오는데 sd로 부팅하니 mmcblk1 : mmc1:0001 8GTF4R 7.28 GiB 라고 나오는걸 보면

/dev/mmcblk1이 emmc

/dev/mmcblk2 가 sdcard인것 같은데

스크립트 내용으로는 sdcard 변수가 emmc 경로여야 한다.

파일 전체 수정으로 emmc 라고 이름을 좀 바꿔주던가 헷갈리구루

#!/bin/bash

if [ "$(id -u)" != "0" ]; then
   echo "Script must be run as root !"
   exit 0
fi


echo ""
date
echo -e "\033[36m==============================="
echo "Installing Linux system to emmc"
echo -e "===============================\033[37m"
setterm -default
echo ""

_format=${1}

fatsize=64

sdcard="/dev/mmcblk1"
odir="/tmp/_extdir"
bootdir="/tmp/_fatdir"

if [ ! -b ${sdcard}boot0 ]; then
    echo "Error: EMMC not found."
    exit 1
fi
if [ ! -f /boot/boot0_OPI.fex ]; then
    echo "Error: boot0_OPI.fex not found."
    exit 1
fi
if [ ! -f /boot/u-boot_OPI-emmc.fex ]; then
    echo "Error: u-boot_OPI-emmc.fex not found."
    exit 1
fi

umount ${sdcard}* > /dev/null 2>&1
#----------------------------------------------------------
echo ""
echo -n "WARNING: EMMC WILL BE ERASED !, Continue (y/N)?  "
read -n 1 ANSWER

if [ ! "${ANSWER}" = "y" ] ; then
    echo "."
    echo "Canceled.."
    exit 0
fi
echo ""
#----------------------------------------------------------

echo "Erasing EMMC ..."
dd if=/dev/zero of=${sdcard} bs=1M count=32 > /dev/null 2>&1
sync
sleep 1

echo "Creating new filesystem on EMMC ..."
echo -e "o\nw" | fdisk ${sdcard} > /dev/null 2>&1
sync
echo "  New filesystem created on $sdcard."
sleep 1
partprobe -s ${sdcard} > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "ERROR."
    exit 1
fi
sleep 1

echo "Partitioning EMMC ..."
sfat=40960
efat=$(( $fatsize * 1024 * 1024 / 512 + $sfat - 1))
echo "  Creating boot & linux partitions"
sext4=$(( $efat + 1))
eext4=""
echo -e "n\np\n1\n$sfat\n$efat\nn\np\n2\n$sext4\n$eext4\nt\n1\nb\nt\n2\n83\nw" | fdisk ${sdcard} > /dev/null 2>&1
echo "  OK."
sync
sleep 2
partprobe -s ${sdcard} > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "ERROR."
    exit 1
fi
sleep 1

echo "Formating fat partition ..."
dd if=/dev/zero of=${sdcard}p1 bs=1M count=1 oflag=direct > /dev/null 2>&1
sync
sleep 1
mkfs.vfat -n EMMCBOOT ${sdcard}p1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "  ERROR formating fat partition."
    exit 1
fi
echo "  fat partition formated."

dd if=/dev/zero of=${sdcard}p2 bs=1M count=1 oflag=direct > /dev/null 2>&1
sync
sleep 1
if [ "${_format}" = "btrfs" ] ; then
    echo "Formating linux partition (btrfs), please wait ..."
    # format as btrfs
    mkfs.btrfs -O ^extref,^skinny-metadata -f -L emmclinux ${sdcard}p2 > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        echo "ERROR formating btrfs partition."
        exit 1
    fi
else
    echo "Formating linux partition (ext4), please wait ..."
    mkfs.ext4 -L emmclinux ${sdcard}p2 > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        echo "ERROR formating ext4 partition."
        exit 1
    fi
fi
echo "  linux partition formated."

#************************************************************************
echo ""
echo "Instaling u-boot to EMMC ..."
dd if=/boot/boot0_OPI.fex of=${sdcard} bs=1k seek=8 > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "ERROR installing u-boot."
    exit 1
fi
dd if=/boot/u-boot_OPI-emmc.fex of=${sdcard} bs=1k seek=16400 > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR installing u-boot."
exit 0
fi
sync
#************************************************************************


# -------------------------------------------------------------------
    
if [ ! -d $bootdir ]; then
    mkdir -p $bootdir
fi
rm $bootdir/* > /dev/null 2>&1
sync
umount $bootdir > /dev/null 2>&1

if [ ! -d $odir ]; then
    mkdir -p $odir
fi
rm -rf $odir/* > /dev/null 2>&1
sync
umount $odir > /dev/null 2>&1
sleep 1

# ================
# MOUNT PARTITIONS
# ================

if [ "${_format}" = "btrfs" ] ; then
    _mntopt="-o compress-force=lzo"
else
    _mntopt=""
fi

echo ""
echo "Mounting EMMC partitions..."

if ! mount ${sdcard}p1 $bootdir; then
    echo "ERROR mounting fat partitions..."
    exit 1
fi
if ! mount ${_mntopt} ${sdcard}p2 $odir; then
    echo "ERROR mounting linux partitions..."
    umount $bootdir
    exit 1
fi
echo "FAT partitions mounted to $bootdir"
echo "linux partition mounted to $odir"


#-----------------------------------------------------------------------------------------------
echo ""
echo "Copying file system to EMMC ..."
echo ""

#-----------------------------------------------------------------------------------------
rsync -r -t -p -o -g -x --delete -l -H -D --numeric-ids -s --stats / $odir/ > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "  ERROR."
fi
#-----------------------------------------------------------------------------------------
sync

rm $odir/usr/local/bin/fs_resize_warning > /dev/null 2>&1

echo "  Creating \"fstab\""
echo "# OrangePI fstab" > $odir/etc/fstab
if [ "${_format}" = "btrfs" ] ; then
    echo "/dev/mmcblk0p2  /  btrfs subvolid=0,noatime,nodiratime,compress=lzo  0 1" >> $odir/etc/fstab
else
    echo "/dev/mmcblk0p2  /  ext4  errors=remount-ro,noatime,nodiratime  0 1" >> $odir/etc/fstab
fi
echo "/dev/mmcblk0p1  /media/boot  vfat  defaults  0 0" >> $odir/etc/fstab
echo "tmpfs /tmp  tmpfs nodev,nosuid,mode=1777  0 0" >> $odir/etc/fstab
sync

#-----------------------------------------------------------------------------------------
rsync -r -t -p -o -g -x --delete -l -H -D --numeric-ids -s --stats /media/boot/ $bootdir/ > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo "  ERROR."
fi
#-----------------------------------------------------------------------------------------
sync


# UMOUNT
if ! umount $bootdir; then
  echo "ERROR unmounting fat partition."
  exit 1
fi
rm -rf $bootdir/* > /dev/null 2>&1
rmdir $bootdir > /dev/null 2>&1

if ! umount $odir; then
    echo "ERROR unmounting linux partitions."
    exit 0
fi

rm -rf $odir/* > /dev/null 2>&1
rmdir $odir > /dev/null 2>&1
sync

echo ""
echo -e "\033[36m*******************************"
echo "Linux system installed to EMMC."
echo -e "*******************************\033[37m"
setterm -default
echo ""

exit 0

[링크 : https://github.com/loboris/OrangePi-BuildLinux/blob/master/install_to_emmc]

'embeded > orange pi' 카테고리의 다른 글

orange pi 3 못써먹겠네!  (0) 2023.07.07
rk3588 HDMI RX interface  (0) 2023.06.30
android on orange pi 3  (0) 2022.12.07
allwinner A시리즈 백도어  (0) 2022.11.06
orange pi 3 관련 문서  (0) 2022.01.03
Posted by 구차니