Jump to content

how to make SD card bootable on Odroid HC2?


mortee

Recommended Posts

Hi,

I've got an Odroid HC2 with Armbian Buster and OMV on it, and the SD card I used it with got corrupted. So I salvaged all the files from it and backups, and restored the whole file structure onto a new SD card, with an ext4 MBR primary partition.

Now, my concern is, how can I make this bootable? I can boot the HC2 off a throwaway newly installed Armbian, and access the target SD card through a USB card reader.

I could google that armbian-config is used to install the bootloader, but apparently it can only do that to the card which has been used to boot the device in the first place.

Any suggestions?

thanks

Link to comment
Share on other sites

You could figure out what armbian-config does when installing the bootloader and do it manually while changing the relevant paths to your SD card. Or copy the needed files to the new sd card with bootloader.

 

armbian-config source: https://github.com/armbian/config

You will find out, that armbian-config uses the nand-sata-install script: https://github.com/armbian/build/blob/master/packages/bsp/common/usr/sbin/nand-sata-install

In there you find the call 

write_uboot_platform "$DIR" "${root_partition_device}"

This function comes from the uboot package that you installed. 

 

Looking and the DL page of Odroid HC2 (https://www.armbian.com/odroid-hc1/) I see that it uses the XU4 packages. So I went and grabbed the uboot deb for XU4 (https://apt.armbian.com/pool/main/l/linux-u-boot-odroidxu4-current/)

Then I extracted the deb and checked the platform_install.sh script inside:
 

DIR=/usr/lib/linux-u-boot-current-odroidxu4_21.02.0-trunk.62_armhf
write_uboot_platform () 
{ 
    if [[ $2 == /dev/mmcblk* && -b ${2}boot0 ]]; then
        local device=${2}boot0;
        echo 0 > /sys/block/$(basename $device)/force_ro;
        local is_emmc=1;
        signed_bl1_position=0;
        bl2_position=30;
        uboot_position=62;
    else
        local device=${2};
        signed_bl1_position=1;
        bl2_position=31;
        uboot_position=63;
    fi;
    if [[ $is_emmc == 1 ]]; then
        tzsw_position=1502;
    else
        tzsw_position=1503;
    fi;
    env_position=2015;
    dd if=$1/bl1.bin.hardkernel of=$device seek=$signed_bl1_position conv=fsync > /dev/null 2>&1;
    dd if=$1/bl2.bin.hardkernel.720k_uboot of=$device seek=$bl2_position conv=fsync > /dev/null 2>&1;
    dd if=$1/u-boot-dtb.bin of=$device bs=512 seek=$uboot_position conv=fsync > /dev/null 2>&1;
    dd if=$1/tzsw.bin.hardkernel of=$device seek=$tzsw_position conv=fsync > /dev/null 2>&1;
    dd if=/dev/zero of=$device seek=$env_position bs=512 count=32 conv=fsync > /dev/null 2>&1
}
write_uboot_platform_mtd () 
{ 
    if [[ -f $1/rkspi_loader.img ]]; then
        dd if=$1/rkspi_loader.img of=$2 conv=notrunc status=none > /dev/null 2>&1;
    else
        echo "SPI u-boot image not found!";
        exit 1;
    fi
}
setup_write_uboot_platform () 
{ 
    local tmp=$(cat /proc/cmdline);
    tmp="${tmp##*root=}";
    tmp="${tmp%% *}";
    [[ -n $tmp ]] && local part=$(findfs $tmp 2>/dev/null);
    [[ -n $part ]] && local dev=$(lsblk -n -o PKNAME $part 2>/dev/null);
    [[ -n $dev && $dev == mmcblk* ]] && DEVICE="/dev/${dev}"
}

 

There I see the exact dd commands needed to write the uboot.

 

In your case, (as you should have an installed uboot deb on the new sd card), I would only try to write a small script, taken from nand-sata-install that calls write_uboot_platform to the correct sd card.

 

Have a backup ready :) I dont have an Odroid so can't test above steps. This should be seen as a general guide.

 

Hope it helps,

Heisath

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines