FreeBSD for Edge / Edge-V

Any progress on the NVMe support? I have an EDGE-V Basic w/M2X expansion board & NVMe and am willing to help test. Would love to get FreeBSD up and running on this platform. Thank you for all the effort so far, great work.

1 Like

plz ask @SleepWalker! i think he have some news !!!

2 Likes

Hi All.

The last image that supports NVMe
https://mega.nz/#!hFtjQAyZ!XX6kiUoa5UJb_5uD2-6Gitgh6M0r8oiDH1D-byKKR5g

4 Likes

Very cool, I’ll check that out.

Is it possible to boot from NVMe?

Mainline u-boot does not yet support booting from NVMe.
This is a preliminary test version of the NVMe driver, on my m.2 drive intel is not stable.
SD card and eMMC work fine.

Oh ok. How do you access the serial terminal? Or should it come up with DHCP? I didn’t realize HDMI was still on the TODO list and can’t tell if it’s booting. :slight_smile: I do see link on the ethernet…

1Gbit Ehternet works fine, dhcp is enabled by default, login is possible through the console (root without password) via ssh login is possible by user: admin with password: admin

4 Likes

i put this image there

INFO: from @SleepWalker

While trying to find the cause of the unstable operation of USB and PCIE.

A thermal sensor driver has been added to the system and now the processor frequency decreases automatically when the load is high and the temperature rises.

The main players got their PINEBOOK PRO on RK3399 and now the debugging system will move faster. We expect drm driver to write from @manu, I hope a video appears, all my fixes are in the source tree and FreeBSD can be built for khadas just from mainline.

1 Like

Today I’m testing the img provide by @SleepWalker. The NVME drive on PCIE does crash randomly, but the SATA to PCIE card(based on Marvell 9235) working perfectly on 2 disk mirror zfs setup for 2 hour intensive writing test. So I assume the PCIE driver is working, the problem is the NVME part.

I’m going to buy another 2 hard drive to test 4 disks raidz1 zfs setup and report the NVME bug to FreeBSD

Just to check, to use this image, I write it to a microSD card and it will boot? Is there anything else I have to do? I’m not seeing any DHCP requests and don’t currently have access to a serial cable (I ordered one though!). I might try taking off the M2X board to see if that’s causing it to not boot or something.

Edit: no difference without the M2X board.

My another 2 Hard drive has arrived today, so I have 4 350G 3.5 inch drive for zfs benchmark. Here’s the results using iozone:

4 Stripe:

2 * 2 Mirrors

4 disk raidz1

The read result is good, but the write throughput in raidz setup hasn’t been doubled as it should.

More updates:
with @mmel’s RK808 regulator’s driver updates, the heat dissipation of RK3399 is vastly improved, only a passive heatsink required for a touchable temperature.

The NVME drive however has some problem, I’ve submit a Bug report

With a stable NVME drive RK3399 will be a powerful FreeBSD developing platform

1 Like

To boot from sd card, you must first clean eMMC
for example, the dd command on Linux or
Start krescue -> advanced -> erase mmc ! (its works every time).
If eMMC is empty, you will successfully boot from the SD card.

Hi All!
The new build of FreeBSD 13.0-CURRENT is available for download,
NVMe M.2 disk is stable.
FreeBSD-aarch64-13-EXPERT-Khadas-EDGE-V-20200116.img
Important:
To start with the SD Card, you must reset the eMMC flash.

Screenshot attached.

3 Likes

Hmm, I’m a little nervous about erasing the eMMC, as it’s how I can currently reliably tell that the unit still works because it will always boot into the stock Android.

Is there any way to get this image to boot from sdcard without erasing the eMMC, like the LibreELEC images? I tried the hack in the thread, where you copy u-boot from a known good image, but unfortunately it didn’t work. (I figured it wouldn’t, but wanted to try.)

That is great progress! I can’t wait to try it.

Thank you for all the great work and help @SleepWalker, I’ve now got FreeBSD 13-CURRENT running on my EDGE-V! It’s using the NVMe for /usr, swap, /var, and /tmp quite successfully.

I noticed that the fan runs 100% of the time and investigated. I see in dmesg it is enumerated from the DTB correctly:

ofwbus0: <pwm-fan> compat pwm-fan (no driver attached)

But there is no pwm-fan driver on FreeBSD as there is in Linux. I found the source code @ https://github.com/torvalds/linux/blob/master/drivers/hwmon/pwm-fan.c but it is beyond my ability to port this driver over, even assuming any dependencies already exist.

I did discover, however, that both pwm0 and pwm1 can be controlled via the command line using the pwm command:

pwm -f /dev/pwm/pwmc0.0 -D will disable the fan
pwm -f /dev/pwm/pwmc0.0 -E -d 0 -p 0 will enable the fan

The -d represents the duty cycle (in nanoseconds/percentage) and -p represents the period (nanoseconds).

Edit:

Ok, with some guidance from a friend, I was able to get the PWM working correctly. I adapted the script to be more daemon-able and it appropriately slows the fan with the temperature. I created two scripts:

/usr/local/bin/fan.sh - the actual PWM logic
/usr/local/etc/rc.d/pwmfan - the service script

Here is fan.sh:

#!/bin/sh
# fan.sh - automatic control of PWM fan on RK3399

trap quit_fan SIGINT SIGSTOP SIGTERM SIGQUIT

quit_fan() {
    pkill -P $$ sleep
    exit
}

MINTEMP=35
MAXTEMP=50

SYSCTL="/sbin/sysctl"
CUT="/usr/bin/cut"
PWM="/usr/sbin/pwm"
PWM_DEVICE="/dev/pwm/pwmc0.0"

while [ TRUE ]; do
    TEMP=`${SYSCTL} -n hw.temperature.CPU | ${CUT} -d . -f 1`
    DISABLE=0
    if [ "$TEMP" -gt ${MAXTEMP} ]; then
        # set speed to maximum
        PERCENTAGE=0
    elif [ "$TEMP" -le ${MINTEMP} ]; then
        # set speed to minimum
        PERCENTAGE=100
        DISABLE=1
    else
        PERCENTAGE=$((TEMP - MINTEMP))
        PERCENTAGE=$(((PERCENTAGE * 100) / 15))
        echo "Temperature is ${TEMP}, which is percentage ${PERCENTAGE}."
        PERCENTAGE=$((100 - PERCENTAGE))
    fi

    if [ $DISABLE -eq "1" ]; then
       ${PWM} -f ${PWM_DEVICE} -D
    else
        if [ "${PERCENTAGE}" -eq 0 ]; then
            ${PWM} -f ${PWM_DEVICE} -E -d 0 -p 0
        else
            ${PWM} -f ${PWM_DEVICE} -E -d ${PERCENTAGE}% -p 30000
        fi
    fi

    sleep 60 &
    wait $!
done

And here is the service script:

#!/bin/sh
# PWMFAN - rc.d script to control RK3399 PWM fan
# PROVIDE: pwmfan
# REQUIRE: DAEMON

# Enable this script by adding:
# pwmfan_enable="YES"
# ... to /etc/rc.conf

. /etc/rc.subr

# Set the default
: ${pwmfan_enable:="NO"}
: ${pwmfan_runuser:="operator"}

name="pwmfan"
rcvar="pwmfan_enable"

# This is the tool init launches
command="/usr/sbin/daemon"
pidfile="/var/run/${name}.pid"

# This is the tool daemon launches
task="/usr/local/bin/fan.sh"
procname="/bin/sh"

command_args="-f -p ${pidfile} -u ${pwmfan_runuser} ${task}"

load_rc_config $name
run_rc_command "$1"

Make sure both scripts are executable (chmod a+x /usr/local/etc/rc.d/pwmfan /usr/local/bin/fan.sh) and then you can enable & start the service: sysrc pwmfan_enable="YES" ; service pwmfan start

4 Likes

Hi @Sleepwalker !
do u have any news/progress about freebsd for EDGE?

Unfortunately NVMe is only stable when disabling the two A72 cores. Hopefully that is fixed soon. Otherwise, it is very stable and awesome!

1 Like