Building Milk V Duo image on Windows (Wsl Ubuntu 22.04 )

Instructions on How i successfully built Milk V Duo Image on Windows 11 with Wsl.

After you have installed Ubuntu 22.04 dependencies in your wsl destro.

sudo apt install -y pkg-config build-essential ninja-build automake autoconf libtool wget curl git gcc libssl-dev bc slib squashfs-tools android-sdk-libsparse-utils jq python3-distutils scons parallel tree python3-dev python3-pip device-tree-compiler ssh cpio fakeroot libncurses5 flex bison libncurses5-dev genext2fs rsync unzip dosfstools mtools tcl openssh-client cmake expect

  1. Format an external drive as Ext4 ( With Live USB version of Linux or a Tool )

  2. Mount the drive in Admin Terminal. Do not worry that it didn’t mount. We just need it to be attached to wsl. On windows the drive will go “offline” meaning windows will see the drive as offline and you cant access it from windows side. My external is Disk4 in Windows so it corresponds to "PHYSICALDRIVE4 ". So if your External is Disk3 then yours would be "PHYSICALDRIVE3 ". “–name” specifies what name to give the drives mount point. For me i chose “h” so under wsl it will be located at /mnt/wsl/h

wsl --mount \\.\PHYSICALDRIVE4  --name  h  --type ext4
  1. start your wsl distribution
wsl --d Ubuntu-22.04

I always login as root btw ( sudo su)

  1. Mount the filesystem. For me the external drive is “/dev/sdc” but the device is “/dev/sdc1”. You can find it out using the info from dmesg. “h” is the mountpoint we created earlier
mount /dev/sdc1 /mnt/wsl/h --type ext4
  1. To check if it was sucessful
ls /mnt/wsl

the mountpoint directory should be blue.

or Run the mount command again
and it should say whats below if succesful.

mount: /mnt/wsl/h: /dev/sdc1 already mounted on /mnt/wsl/h.

If it fails then try a different tool to format the external as ext4. I used Ubuntu 24.04 live USB to format the drive.

  1. Go into the directory you want to download buildroot in ( On the ext4 drive ofc). For me its in /mnt/wsl/h/Duo/Arduino. You can create your own directories with mkdir. if your ext4 filesystem has no folders yet ( e.g " mkdir /mnt/h/Duo " then " mkdir /mnt/h/Duo/Arduino ").
cd  /mnt/wsl/h/Duo/Arduino/duo-buildroot-sdk
  1. download repo from github. “arduino” for arduino branch and “develop” for developer branch. Theres a 3rd branch but not interested in it.
git clone --branch arduino --single-branch https://github.com/milkv-duo/duo-buildroot-sdk.git --depth=1 
  1. Start Automated build process.
./build.sh lunch
  1. When the script runs i will ask which option you want to build. For me i was building spinor version so i chose option 3
Pressed 3 then Enter
  1. It will download the build tools which is around 850 MB. After it will extract it and start building the image. You will greeted with this message at the end of build.
 [TARGET] system
python3 /mnt/wsl/h/Duo/Arduino/duo-buildroot-sdk/build/tools/common/image_tool/raw2cimg.py /mnt/wsl/h/Duo/Arduino/duo-buildroot-sdk/install/soc_cv1800b_milkv_duo_spinor/rawimages/system.spinor /mnt/wsl/h/Duo/Arduino/duo-buildroot-sdk/install/soc_cv1800b_milkv_duo_spinor /mnt/wsl/h/Duo/Arduino/duo-buildroot-sdk/build/boards/cv180x/cv1800b_milkv_duo_spinor/partition/partition_spinor.xml
INFO: Packing /mnt/wsl/h/Duo/Arduino/duo-buildroot-sdk/install/soc_cv1800b_milkv_duo_spinor/upgrade.zip done!
Build board milkv-duo-spinor success!
Create spinor/nand img successful: milkv-duo-spinor-20240822-0931

Do not copy the repo from NTFS to the Ext4 drive. It will not work and have build errors if you do.

Also after you mount the drive in wsl. Your drive is accessible in windows under \\wsl.localhost\Ubuntu-22.04/mnt/wsl/h.

2 Likes

You mean, this won’t work because NTFS is case-insensitive, while Ext4 is?

On normal NTFS some files get overritten because of case insensitivity but
NTFS supports case sensitivity but its disabled by default. You can enable case sensitivity on NTFS, per folder.

//Enable case sensitivity

fsutil.exe file SetCaseSensitiveInfo <Directory> enable

But I already tried this on NTFS but builds still fail . So it might be another issue causing that. So rather than wasting more time. Its better to use an external drive with ext4 on Wsl.

Its probably the brmake util that doesnt like NTFS. Since it fails when building packages which goes in rootfs.

2 Likes