=> 63 62333889 da1 MBR (30G)
63 32705 - free - (16M)
32768 491520 1 fat32 [active] (240M)
524288 61808640 2 linux-data (29G)
62332928 1024 - free - (512K)
echo "Run Khadas boot script"
# Constant
setenv BOARD_TYPE_NONE 0
setenv BOARD_TYPE_EDGE 1
setenv BOARD_TYPE_EDGE_V 2
setenv BOARD_TYPE_CAPTAIN 3
# Detect board type
kbi boarddetect
if test ${board_type} = ${BOARD_TYPE_NONE}; then
echo "Unsupported board detected! Stop here. Reboot...";
sleep 5;
reset;
fi
setenv emmc_root_part 7
setenv emmc_boot_part 7
setenv emmc_mbr_root_part 2
setenv emmc_mbr_boot_part 1
setenv sd_root_part 2
setenv sd_boot_part 1
if test ${devnum} = 0; then
echo "Uboot loaded from eMMC.";
if test -e mmc ${devnum}:${emmc_root_part} zImage; then
setenv imagetype "EMMC";
setenv boot_env_part ${emmc_boot_part};
setenv root_part ${emmc_root_part};
setenv mark_prefix "boot/";
else
setenv imagetype "EMMC_MBR";
setenv boot_env_part ${emmc_mbr_boot_part};
setenv root_part ${emmc_mbr_root_part};
setenv mark_prefix "";
fi;
if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then
setenv default_rootdev "/dev/mmcblk2p${root_part}"
else
setenv default_rootdev "/dev/mmcblk1p${root_part}"
fi
else if test ${devnum} = 1; then
echo "Uboot loaded from SD.";
setenv boot_env_part ${sd_boot_part};
setenv root_part ${sd_root_part}
setenv mark_prefix ""
if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then
setenv default_rootdev "/dev/mmcblk1p${sd_root_part}"
else
setenv default_rootdev "/dev/mmcblk0p${sd_root_part}"
fi
setenv imagetype "SD-USB";
fi;fi;
# Import environment from env.txt
if load ${devtype} ${devnum}:${boot_env_part} ${ramdisk_addr_r} /boot/env.txt || load ${devtype} ${devnum}:${boot_env_part} ${ramdisk_addr_r} env.txt; then
echo "Import env.txt";
env import -t ${ramdisk_addr_r} ${filesize}
fi
# Check root part filesystem UUID
fsuuid ${devtype} ${devnum}:${root_part} root_uuid
if test "UUID=${root_uuid}" != "${rootdev}"; then
echo "Rootfs UUID mismatch! Set rootfs part to default: ${default_rootdev}"
setenv rootdev ${default_rootdev}
fi
# Check MIPI
if test "${mipi_lcd_enabled}" = "true"; then
setenv dtb_suffix "-mipi";
else
setenv dtb_suffix "";
fi
if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then
if test ${board_type} = ${BOARD_TYPE_EDGE}; then
setenv boot_dtb "rk3399-khadas-edge.dtb";
else if test ${board_type} = ${BOARD_TYPE_EDGE_V}; then
setenv boot_dtb "rk3399-khadas-edge-v.dtb";
else if test ${board_type} = ${BOARD_TYPE_CAPTAIN}; then
setenv boot_dtb "rk3399-khadas-edge-captain.dtb";
fi;fi;fi
else
if test ${board_type} = ${BOARD_TYPE_EDGE}; then
setenv boot_dtb "rk3399-khadas-edge-linux.dtb";
else if test ${board_type} = ${BOARD_TYPE_EDGE_V}; then
setenv boot_dtb "rk3399-khadas-edgev${dtb_suffix}-linux.dtb";
else if test ${board_type} = ${BOARD_TYPE_CAPTAIN}; then
setenv boot_dtb "rk3399-khadas-captain${dtb_suffix}-linux.dtb";
fi;fi;fi
fi
if test ${devnum} = 0; then
if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then
if test ${imagetype} = EMMC_MBR; then
setenv dtb_prefix "/dtb/rockchip/";
else
setenv dtb_prefix "/boot/dtb/rockchip/";
fi
else
if test ${imagetype} = EMMC_MBR; then
setenv dtb_prefix "/dtb/";
else
setenv dtb_prefix "/boot/dtb/";
fi
fi
else if test ${devnum} = 1; then
if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then
setenv dtb_prefix "/dtb/rockchip/";
else
setenv dtb_prefix "/dtb/";
fi
fi;fi;
echo DTB: ${dtb_prefix}${boot_dtb}
if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then
setenv condev "earlyprintk console=ttyS2,1500000n8 console=tty0"
else
setenv condev "earlyprintk console=ttyFIQ0,1500000n8 console=tty0"
fi
setenv boot_start booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
part uuid mmc ${devnum}:1 ubootpartuuid;
if test "X${ubootpartuuid}" = "X"; then
echo "Can not get u-boot part UUID, set to NULL";
setenv ubootpartuuid "NULL";
fi;
kbi ethmac
if test -e ${custom_ethmac}; then
echo "Found custom ethmac: ${custom_ethmac}, overwrite eth_mac!";
setenv eth_mac ${custom_ethmac}
fi
if test "X${eth_mac}" = "X" || test "X${eth_mac}" = "X00:00:00:00:00:00"; then
echo "Set default mac address to ethaddr: ${ethaddr}!";
setenv eth_mac ${ethaddr};
setenv saveethmac "save_ethmac=yes";
fi;
if test -e ${loglevel}; then
setenv log "loglevel=${loglevel}"
fi
setenv bootargs "${bootargs} ${condev} ${log} rw root=${rootdev} rootfstype=ext4 init=/sbin/init rootwait ubootpart=${ubootpartuuid} board_type=${board_type} board_type_name=${board_type_name} khadas_board=${board_type_name} fan=${fan_mode} mac=${eth_mac} androidboot.mac=${eth_mac} ${saveethmac} coherent_pool=${dma_size} imagetype=${imagetype}"
for distro_bootpart in ${devplist}; do
echo "Scanning ${devtype} ${devnum}:${distro_bootpart}..."
if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} uInitrd; then
if load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} zImage; then
if load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${dtb_prefix}${boot_dtb}; then
run boot_start;
fi;
fi;
fi;
done
# Rebuilt
# mkimage -A arm64 -O linux -T script -C none -a 0 -e 0 -n "rk3399 autoscript" -d /boot/rk3399_autoscript.cmd /boot/boot.scr
=> 40 500006832 da3 GPT (238G)
40 32728 - free - (16M)
32768 102400 1 efi (50M)
135168 483708928 2 freebsd-ufs (231G)
483844096 16154624 3 freebsd-swap (7.7G)
499998720 8152 - free - (4.0M)
marietto# cd /mnt/da3p1
marietto# ls
EFI dtb dtb-rock u-boot~1.bin
Edge-V dtb-RK3399 rk3399_autoscript.cmd ubootefi.var
boot.scr dtb-pinebook-pro splash.bmp ubootefi_.var
Yes they boot a whole different way. Minimal u-boot but add everything in via boot.scr.I suspect that it has been compiled and it became the file "boot.scr" that's the responsible for the booting of Ubuntu from the sd card.
Yes they boot a whole different way. Minimal u-boot but add everything in via boot.scr.
At this point you are wasting your time. Use Ubuntu and blank eMMC.
Prepare a microSD with your custom u-boot for edge-v built on FreeBSD.
Get it booting up on edge-v. No operating system. Just u-boot from microSD card.
Once you achieve that flash ROCKPRO64 14.3-RELEASE to a microSD. Then flash your edge-v u-boot to card and you are done.
if test ${devnum} = 0; then
echo "Uboot loaded from eMMC.";
if test -e mmc ${devnum}:${emmc_root_part} zImage; then
setenv imagetype "EMMC";
setenv boot_env_part ${emmc_boot_part};
setenv root_part ${emmc_root_part};
setenv mark_prefix "boot/";
else
setenv imagetype "EMMC_MBR";
setenv boot_env_part ${emmc_mbr_boot_part};
setenv root_part ${emmc_mbr_root_part};
setenv mark_prefix "";
fi;
if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then
setenv default_rootdev "/dev/mmcblk2p${root_part}"
else
setenv default_rootdev "/dev/mmcblk1p${root_part}"
fi
else if test ${devnum} = 1; then
echo "Uboot loaded from SD.";
setenv boot_env_part ${sd_boot_part};
setenv root_part ${sd_root_part}
setenv mark_prefix ""
if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then
setenv default_rootdev "/dev/mmcblk1p${sd_root_part}"
else
setenv default_rootdev "/dev/mmcblk0p${sd_root_part}"
fi
setenv imagetype "SD-USB";
fi;fi;
if test ${devnum} = 0; then
echo "Uboot loaded from SD.";
setenv boot_env_part ${sd_boot_part};
setenv root_part ${sd_root_part}
setenv mark_prefix ""
if test -e mmc ${devnum}:${boot_env_part} ${mark_prefix}.next; then
setenv default_rootdev "/dev/mmcblk1p${sd_root_part}"
else
setenv default_rootdev "/dev/mmcblk0p${sd_root_part}"
fi
setenv imagetype "SD-USB";
fi;
=> 63 62333889 da0 MBR (30G)
63 32705 - free - (16M)
32768 491520 1 fat32 [active] (240M)
524288 61809664 - free - (29G)
marietto# gpart add -t freebsd-ufs -a 4k -l data da0
gpart: Invalid argument
# sgdisk -g /dev/sdi
======>
Disk /dev/sdi: 29.72 GiB, 31914983424 bytes, 62333952 sectors
Disk model: STORAGE DEVICE
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F36CA327-5194-4815-A69E-11ADBB6A4053
Dispositivo Start Fine Settori Size Tipo
/dev/sdi1 32768 524287 491520 240M Microsoft basic data
# gpart create -s MBR da7
# gpart add -t freebsd -s 119G -a 4k da7
# gpart set -a active -i 1 da7
# gpart bootcode -b /boot/boot0 da7
# gpart create -s BSD -n 20 da7s1
=> 63 249737153 da7 MBR (119G)
63 1985 - free - (993K)
2048 102400 1 fat32lba [active] (50M)
104448 249561088 2 freebsd (119G)
249665536 71680 - free - (35M)
# gpart list da7 | grep rawuuid
nothing.
marietto# tune2fs -U random /dev/da7s2a
tune2fs 1.47.2 (1-Jan-2025)
tune2fs: Bad magic number in super-block while trying to open /dev/da7s2a
/dev/da7s2a contains `Unix Fast File system [v2] (little-endian) last mounted on /mnt/da7s2a,
volume name rootfs, last written at Sun Jul 13 17:13:21 2025, clean flag 1, readonly flag 0,
number of blocks 1297648, number of data blocks 1252407, number of cylinder groups 9,
block size 32768, fragment size 4096, average file size 16384, average number of files in dir 64,
pending blocks to free 0, pending inodes to free 0, system-wide uuid 0,
minimum percentage of free blocks 8, TIME optimization' data
FreeBSD does not need boot.scr as it boots via the U-boot build method called FIT image.
Everything is included on the u-boot image and it has a copy of the DTB build in. Nothing more is needed.
It is really disappointing to try and lead someone and then watch them fall into a volcano.
Yes they boot a whole different way. Minimal u-boot but add everything in via boot.scr.
At this point you are wasting your time. Use Ubuntu and blank eMMC.
Prepare a microSD with your custom u-boot for edge-v built on FreeBSD.
Get it booting up on edge-v. No operating system. Just u-boot from microSD card.
Once you achieve that flash ROCKPRO64 14.3-RELEASE to a microSD. Then flash your edge-v u-boot to card and you are done.
All you have to do is create a directory and 2 files...Here is step by step what I do to build u-boot for this platform.
Do you understand this part? You are looking for a default configuration file for Khadis Edge V. I am using another port to do this.
You could just as easily build any board port for this u-boot source tree.
Once you have this information (the name of defconfig file)
marietto# pwd
/usr/ports/sysutils/u-boot-khadas-edge-v
marietto# make build-depends-list | cut -c 12- | xargs pkg install -A -y
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
pkg: No packages available to install matching 'misc/e2fsprogs-libuuid' have been found in the repositories
You can skip the whole line. What it does is download the package instead of building a port.make build-depends-list | cut -c 12- | xargs pkg install -A -y
make install
. It will take a bit longer.marietto# MAKE_JOBS_UNSAFE=yes make install
.....
In file included from tools/aisimage.c:7:
In file included from tools/imagetool.h:24:
In file included from include/image.h:19:
In file included from ./arch/arm/include/asm/byteorder.h:18:
In file included from ./arch/arm/include/asm/types.h:4:
include/asm-generic/int-ll64.h:28:44: error: typedef redefinition with different types ('long long' vs 'int64_t' (aka 'long'))
28 | __extension__ typedef __signed__ long long __s64;
| ^
/usr/local/include/linux/types.h:22:17: note: previous definition is here
22 | typedef int64_t __s64;
| ^
In file included from tools/aisimage.c:7:
In file included from tools/imagetool.h:24:
In file included from include/image.h:19:
In file included from ./arch/arm/include/asm/byteorder.h:18:
In file included from ./arch/arm/include/asm/types.h:4:
include/asm-generic/int-ll64.h:29:42: error: typedef redefinition with different types ('unsigned long long' vs 'uint64_t' (aka 'unsigned long'))
29 | __extension__ typedef unsigned long long __u64;
| ^
/usr/local/include/linux/types.h:9:18: note: previous definition is here
9 | typedef uint64_t __u64;
| ^
In file included from tools/aisimage.c:7:
In file included from tools/imagetool.h:24:
In file included from include/image.h:19:
In file included from ./arch/arm/include/asm/byteorder.h:28:
include/linux/byteorder/little_endian.h:45:15: error: unknown type name '__le64'
45 | static inline __le64 __cpu_to_le64p(const __u64 *p)
| ^
include/linux/byteorder/little_endian.h:47:18: error: use of undeclared identifier '__le64'
47 | return (__force __le64)*p;
| ^
include/linux/byteorder/little_endian.h:49:42: error: unknown type name '__le64'
49 | static inline __u64 __le64_to_cpup(const __le64 *p)
| ^
include/linux/byteorder/little_endian.h:53:15: error: unknown type name '__le32'
53 | static inline __le32 __cpu_to_le32p(const __u32 *p)
| ^
include/linux/byteorder/little_endian.h:55:18: error: use of undeclared identifier '__le32'
55 | return (__force __le32)*p;
| ^
include/linux/byteorder/little_endian.h:57:42: error: unknown type name '__le32'
57 | static inline __u32 __le32_to_cpup(const __le32 *p)
| ^
include/linux/byteorder/little_endian.h:61:15: error: unknown type name '__le16'
61 | static inline __le16 __cpu_to_le16p(const __u16 *p)
| ^
include/linux/byteorder/little_endian.h:63:18: error: use of undeclared identifier '__le16'
63 | return (__force __le16)*p;
| ^
include/linux/byteorder/little_endian.h:65:42: error: unknown type name '__le16'
65 | static inline __u16 __le16_to_cpup(const __le16 *p)
| ^
include/linux/byteorder/little_endian.h:69:15: error: unknown type name '__be64'
69 | static inline __be64 __cpu_to_be64p(const __u64 *p)
| ^
include/linux/byteorder/little_endian.h:71:18: error: use of undeclared identifier '__be64'
71 | return (__force __be64)__swab64p(p);
| ^
include/linux/byteorder/little_endian.h:73:42: error: unknown type name '__be64'
73 | static inline __u64 __be64_to_cpup(const __be64 *p)
| ^
include/linux/byteorder/little_endian.h:77:15: error: unknown type name '__be32'
77 | static inline __be32 __cpu_to_be32p(const __u32 *p)
| ^
include/linux/byteorder/little_endian.h:79:18: error: use of undeclared identifier '__be32'
79 | return (__force __be32)__swab32p(p);
| ^
include/linux/byteorder/little_endian.h:81:42: error: unknown type name '__be32'
81 | static inline __u32 __be32_to_cpup(const __be32 *p)
| ^
include/linux/byteorder/little_endian.h:85:15: error: unknown type name '__be16'
85 | static inline __be16 __cpu_to_be16p(const __u16 *p)
| ^
include/linux/byteorder/little_endian.h:87:18: error: use of undeclared identifier '__be16'
87 | return (__force __be16)__swab16p(p);
| ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
gmake[1]: *** [scripts/Makefile.host:112: tools/aisimage.o] Error 1
gmake: *** [Makefile:1918: tools] Error 2
*** Error code 1
Stop.
make: stopped in /usr/ports/sysutils/u-boot-khadas-edge-v
make clean
? It looks like your toolchain is not setup right.Disk /dev/sdg: 29.72 GiB, 31914983424 bytes, 62333952 sectors
Disk model: STORAGE DEVICE
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: C06DC639-CC50-11EB-B8A0-D03745CD5653
Dispositivo Start Fine Settori Size Tipo
/dev/sdg1 32768 135167 102400 50M EFI System
/dev/sdg2 135168 659455 524288 256M FreeBSD swap
/dev/sdg3 659456 2874879 2215424 1.1G FreeBSD UFS
# dd if=edge-freebsd-aarch64-13.0-release-20210613.img | pv | dd of=/dev/sdg
# dd if=idbloader.img of=/dev/sdg seek=64 conv=sync
# dd if=u-boot.itb of=/dev/sdg seek=16384 bs=512 conv=sync
What about the buttons. Now that you have a bootable card you need the proper button sequence.Android booted instead of FreeBSD.
What kind of SD / microSD card socket is on the Khadas? Some have a "push in until it clicks" type socket.
Are you certain that the SD / microSD card is properly inserted?
What about the buttons. Now that you have a bootable card you need the proper button sequence.
We need to check why you cant boot from the SD card, please follow the below steps to provide the full serial debug console log to us.
- Setup the serial debug console [1]
- Write FreeBSD [2] image to the SD card
- Insert the SD card to Edge-V
- Quick press the Func 3 times, you will see the Blue LED flash and the board will reboot
- Provide the full serial debug console log to us
dd if=/dev/da0 | hexdump -C | more
dd if=/dev/da0 | hexdump -C | grep RK