FreeBSD for Edge / Edge-V

Linux / Android command line :

UPDATE :

I’ve been able to boot this image file from the sd card using serial mode :

Edge_Ubuntu-gnome-focal_Linux-
5.7_arm64_SD-USB_V0.9.1-20200602.img

configured like this :

but this image : edge-freebsd-aarch64-13.0-release-20210613.img

is NOT able to boot. At this point I’m sure that I’ve configured correctly the serial connection and the error is inside the FreeBSD image,because it is not able to boot,but Edge_Ubuntu-gnome-focal_Linux- it is.

So,now that the situation is more clear,you understand what’s wrong and you can help me to boot FreeBSD.

I’m not sure why FreeBSD cant boot on your side but it works well on my side, please provide the full serial debug console log when you try to boot FreeBSD.

I don’t know how to “provide the full serial debug console log when you try to boot FreeBSD” because I presume that the board goes in upgrade mode using only the serial connection and with one only kind of img files (if it booted from the sd card I presume the board went in upgrade mode,right ?)

I think that only the sd-usb image files are able to boot from the sd card.
What’s special with these images ? I’m more interested to install Linux or FreeBSD on the internal EMMC than on the sd card. Even because I can’t setup a serial connection everytime I want boot something from the sd card.

  1. Write oowow to SD card
  2. Boot oowow from the SD card
  3. Using oowow to install FreeBSD to the eMMC

Hello.

How much large is the internal EMMC ? Does oowow require an ISO image to be able to install FreeBSD to the eMMC ? Or it can accept an *.img file ?

It depends on your Edge-V version.

  • Basic:
    • 2GB LPDDR4X
    • 16GB eMMC
  • Pro:
    • 4GB LPDDR4X
    • 32GB eMMC
  • Max:
    • 4GB LPDDR4X
    • 128GB eMMC

No, when you boot into oowow, navigate to: Wizard->edge-freebsd… ->Okay->Download->Continue->Install.

to install the FreeBSD to eMMC. After installation reomve the SD card and reboot.



I’ve bought the pro version,so I have 32 GB of space on the EMMC. It’s a little space. I don’t know if it worths to install FreeBSD on the EMMC. This is not a good situation. Because I’m not able to boot it from the sd card and I have a little space on the EMMC. Anyway,there is no sense today to install FreeBSD 13 on the board,because it is EOL. I have configured my own FreeBSD version (14.2) that I want to test on the edge-V. How can I “upload” my image instead of the 13.0 ? I’m thinking that I can modify the appropriate config file located inside the “edge-oowow-latest-sd.img” file to be able to download my image file instead of your ? So basically changing the source link,changing your with my link,located on my server. How can I do this ? or ? do you have another idea ?

Hello @Mario_Marietto

You can use the oowow WEB API to write your own image to eMMC via oowow.

The instructions aren’t complete or exaustive. For example :

curl OOWOW_HOST_NAME_OR_IP/shell/write | sh -s - IMAGE

curl is a linux command. In which kind of context we are here ? Is oowow a mini linux distro ? Since I see a graphical GUI,I imagine that pressing CTRL + F1,I can access to a Linux terminal and I can write that command ?

OOWOW_HOST_NAME_OR_IP : which IP is this ? Should I tuck up my own (SAMBA) server ?

shell/write : where are located these commands ?

sh -s - IMAGE : where/how the IMAGE should be uploaded ?

In my opinion I see a lot of un-necessary complications. I would like that you avoided to build all these not useful infrastructure. A lot of boards don’t have this and they are easier to use.

Furthermore you are giving a lot of confused informations on your website.

How can I boot another OS from the SD card before booting the OS installed on the EMMC ? that’s only what I need to know.

I don’t want to press keys or configuring serial connections or even “using a tweezer to short-circuit the two pads of M register” every time that I want to boot an OS from the SD-CARD.

Do you realize that all this is useless and only creates complications ?

I don’t want to be involved in cumbersome procedures.

This command is issue on your Linux host PC.

OOWOW_HOST_NAME_OR_IP - if your Edge-V with oowow system IP
IMAGE - is your image want to install to the eMMC

As I said above you can quick press the FUNC 3 time to boot from the SD card, it works on my side with no issues.

—> OOWOW_HOST_NAME_OR_IP - if your Edge-V with oowow system IP
IMAGE - is your image want to install to the eMMC

I don’t understand,sorry. You have introduced a lot of elements in the equation without explaining how they are interconnected.

-) OOWOW
-) my host PC
-) my EDGE-V with oowow system IP image

what else ? What’s OOWOW ? Where I get it ? should I install it on my PC or on the Edge-V board ?

Actlually I’m only able to boot the VERY OLD Ubuntu 18.04 on the EMMC through a cumbersome Serial connection. Do you mean that I should use this OS ? are you calling this OS as “Linux host PC” ?

—> As I said above you can quick press the FUNC 3 time to boot from the SD card, it works on my side with no issues.

It does not work for me. But it does not work even the other options that you are offering (TST Mode ; Key Mode ; [Linux / Android Command Line : all these don’t work).

Even if one of those options worked,it’s very uncomfortable to boot the OS from the SD CARD everytiime pressing some keys or shorting pins or configuring a serial connection. Can u understand this ? The booting of the OS from the Sd card should not happens immediately and automatically ?
This is very important,since on the EMMC I have only 32 GB of space,on the sd card I have an unlimited amount of space.

Please don’t assume that if it works for you,so it SHOULD work also for me. This assumption could be wrong. At least should be verified the reasons why for me 3 booting modes don’t work before to settle the matter).

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.

  1. Setup the serial debug console [1]
  2. Write FreeBSD [2] image to the SD card
  3. Insert the SD card to Edge-V
  4. Quick press the Func 3 times, you will see the Blue LED flash and the board will reboot
  5. Provide the full serial debug console log to us

[1] - Edge1 Setup Serial Debug Console [Khadas Docs]
[2] - https://dl.khadas.com/products/oowow/images/edge/edge-freebsd-aarch64-13.0-release-20210613.img.xz

I will try,but I already know what will happen. If I use an image different than one of the images that include “sd-usb”,like these ones :

edge_ubuntu-gnome-focal_linux-5.7_arm64_sd-usb_v0.9.1-20200602.7z

edge_ubuntu-lxde-bionic_linux-4.4_arm64_sd-usb_v1.0.10-220108.img.xz

edge_ubuntu-server-bionic_linux-4.4_arm64_sd-usb_v1.0.10-220108.img.xz

edge_ubuntu-server-focal_linux-5.16-rc2_arm64_sd-usb_v1.0.10-220108.img.xz

edge_ubuntu-server-focal_linux-5.7_arm64_sd-usb_v0.9.1-20200602.7z

pressing the buttons will not work and if the image is not like that it will not boot even using a serial mode connection. It depends about the OS that’s on the sd card. So,think carefully about which kind of mechanism is inside that kind of images that isn’t present on the FreeBSD image.

In addition I have already showed you that I pressed 3 times the FUNC button and it didn’t work. Did u watch the video that I have posted and that you have asked me to produce ? Really I have attached more than one video,but you said nothing about that. I don’t know if you did it or not ; I don’t know if you said nothing because I didn’t make mistakes.

Ok I tried. WIth and without the USB-C OTG cable attached. Because you didn’t explain if I should have attached it or not. What happened ? what I supposed before. When I quick press the Func 3 times I see the white LED turns on together with the red one and the board reboots,booting Android.

I’ve understood that the image named “Edge_Ubuntu-gnome-focal_Linux-5.7_arm64_SD-USB_V0.9.1-20200602.img” can boot from the sd card,but the image named “edge-freebsd-aarch64-13.0-release-20210613.img” can’t do it. Why ? I’ve crudely identified some crucial differences that make the magic.

  1. the structure of the disk partitions that comes after having written “Edge_Ubuntu-gnome-focal_Linux-5.7_arm64_SD-USB_V0.9.1-20200602.img” to the sd card :

Code:

=>      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)

I suspect that MBR here is important. Anyway,not totally sure.

  1. inside the fat32 partition there is a script like this :

Code:

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

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. This script is not present on the EFI partition of the sd card where is installed FreeBSD :

Code:

=>       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)

anyway,I tried to put it there :

Code:

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

what happens ? that FreeBSD does not boot,but is Android that’s installed on the internal EMMC that makes the boot.

I’m pretty sure that the script has been written specially for Ubuntu and it should be modified to work with FreeBSD. Is my intention to make some modifications,but I feel that this job is not that easy. I need help.

Hello @Mario_Marietto

But you still not provide the full serial debug console log, we the the log to check why it cant boot the FreeBSD, please just provide the logs to us.

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.

  1. Setup the serial debug console [1]
  2. Write FreeBSD [2] image to the SD card
  3. Insert the SD card to Edge-V
  4. Quick press the Func 3 times, you will see the Blue LED flash and the board will reboot
  5. Provide the full serial debug console log to us

I can’t provide the full serial debug to you because when I quick press the Func 3 times, the board will reboot in Android. I don’t have any log to provide. Or I don’t know how to provide it.

Bro,you should read the old posts at least a little bit. It’s not professional to read only the last one. I’ve already explained 2 days ago what happens :

Why not ? Even boot to android it will also has logs from the serial debug console, it will be like this.

Channel 0: LPDDR4, 50MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
Channel 1: LPDDR4, 50MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
256B stride
lpddr4_set_rate: change freq to 400000000 mhz 0, 1
lpddr4_set_rate: change freq to 800000000 mhz 1, 0

U-Boot SPL 2021.07 (Sep 28 2022 - 14:55:25 +0800)
*** BOOT_SOURCE_ID 5 (2:emmc 3:spi 5:sd ...)***
spl_boot: MMC1 > MMC2 > MMC1 > 
Trying to boot from MMC1


U-Boot 2021.07 (Sep 28 2022 - 14:55:25 +0800)

SoC: Rockchip rk3399
Reset cause: POR
Model: Khadas Edge-V
DRAM:  3.9 GiB
PMIC:  RK808 
MMC:   mmc@fe310000: 2, mmc@fe320000: 1, sdhci@fe330000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial
Out:   vidconsole
Err:   vidconsole
Model: Khadas Edge-V
fusb302_init: Device ID: 0x91
Net:   eth0: ethernet@fe300000
Failed to load 'splash.bmp'
** Unrecognized filesystem type **
Can't set block device
** Invalid partition 2 **
Couldn't find partition mmc 1:2
Can't set block device
** Unrecognized filesystem type **
Can't set block device
starting USB...
Bus usb@fe380000: USB EHCI 1.00
Bus usb@fe3a0000: USB OHCI 1.0
Bus usb@fe3c0000: USB EHCI 1.00
Bus usb@fe3e0000: USB OHCI 1.0
Bus dwc3: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe380000 for devices... 1 USB Device(s) found
scanning bus usb@fe3a0000 for devices... 1 USB Device(s) found
scanning bus usb@fe3c0000 for devices... 1 USB Device(s) found
scanning bus usb@fe3e0000 for devices... 1 USB Device(s) found
scanning bus dwc3 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Setting bus to 8
Hit SPACE in 2 seconds to stop autoboot
Device 0: unknown device
rockchip_pcie pcie@f8000000: PCIe link training gen1 timeout!

Device 0: unknown device
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found U-Boot script /boot.ini
9921 bytes read in 5 ms (1.9 MiB/s)
## Script run a:00500000 l:9893 c:0
kbi - Khadas Bootloader Instructions sub-system

Usage:
kbi [function] [mode] [write|read] <value>

kbi version - read version information
kbi usid - read usid information
kbi adc - read adc value
kbi powerstate - read power on state
kbi poweroff - power off device
kbi ethmac - read ethernet mac address
kbi boarddetect - detect board type

kbi led [systemoff|systemon] w <off|on|breathe|heartbeat> - set blue led mode
kbi led [systemoff|systemon] r - read blue led mode

kbi bootmode w <emmc|spi> - set bootmode to emmc or spi
kbi bootmode r - read current bootmode
...

Yes, I see it but it will also has logs.

Where the log file produced by FreeBSD is stored ? How can I watch it ?
As u can see below,no messages are provided by minicom in Linux or SecureCRT in Windows.