Getting the MIPI DBI screen for the Sipeed M1S dock to work on Linux

Image
Background What started out as an activity to clear out unused stuff from my cupboard led on to a small project to get Linux working with the MIPI DBI screen for the Sipeed M1S dock. I first got hold of the Sipeed M1S dock back in December 2022. What tempted me was the rich set of features it supports, all in a really small package -- NPU, WiFi/BT/Zigbee, 3 RISCV cores courtesy of the BL808 SoC from Bouffalo Labs. It was also touted as being able to run Linux owing to one of its RISCV cores having an MMU. Beyond playing around with the SDK and a few examples, I didn't venture further due to poor documentation. Quickly, it went back to a box I've conveniently dedicated for dev boards which were marketed to support all kinds of features but disappointingly lack good documentation and were thus chucked aside until I had more time to mess around. That time finally came, in a period when work has gotten mundane and I needed some mental stimulation. In the process of declutter

vmblock patch for linux 3.10 (vmware 9)

After upgrading to linux 3.10, vmware workstation will have trouble compiling the vmnet and vmblock kernel modules against the latest kernel headers. This is attributed to the removal of create_proc_entry() in favor of proc_create().
  CC [M]  /tmp/modconfig-lEXylP/vmnet-only/driver.o
  CC [M]  /tmp/modconfig-lEXylP/vmnet-only/hub.o
  CC [M]  /tmp/modconfig-lEXylP/vmnet-only/userif.o
  CC [M]  /tmp/modconfig-lEXylP/vmnet-only/netif.o
/tmp/modconfig-lEXylP/vmnet-only/userif.c: In function ‘VNetUserIf_Create’:
/tmp/modconfig-lEXylP/vmnet-only/userif.c:1049:34: error: dereferencing pointer to incomplete type
/tmp/modconfig-lEXylP/vmnet-only/userif.c:1050:34: error: dereferencing pointer to incomplete type
/tmp/modconfig-lEXylP/vmnet-only/hub.c: In function ‘VNetHubAlloc’:
/tmp/modconfig-lEXylP/vmnet-only/hub.c:366:28: error: dereferencing pointer to incomplete type
/tmp/modconfig-lEXylP/vmnet-only/hub.c:367:28: error: dereferencing pointer to incomplete type
make[2]: *** [/tmp/modconfig-lEXylP/vmnet-only/userif.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [/tmp/modconfig-lEXylP/vmnet-only/hub.o] Error 1
/tmp/modconfig-lEXylP/vmnet-only/netif.c: In function ‘VNetNetIf_Create’:
/tmp/modconfig-lEXylP/vmnet-only/netif.c:191:33: error: dereferencing pointer to incomplete type
/tmp/modconfig-lEXylP/vmnet-only/netif.c:192:33: error: dereferencing pointer to incomplete type
make[2]: *** [/tmp/modconfig-lEXylP/vmnet-only/netif.o] Error 1
make[1]: *** [_module_/tmp/modconfig-lEXylP/vmnet-only] Error 2
make[1]: Leaving directory `/home/ricky/kernel_src/linux-3.10'
make: *** [vmnet.ko] Error 2
make: Leaving directory `/tmp/modconfig-lEXylP/vmnet-only'
Using 2.6.x kernel build system.
make: Entering directory `/tmp/modconfig-lEXylP/vmblock-only'
/usr/bin/make -C /lib/modules/3.10.0-custom/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
          MODULEBUILDDIR= modules
make[1]: Entering directory `/home/ricky/kernel_src/linux-3.10'
  CC [M]  /tmp/modconfig-lEXylP/vmblock-only/linux/block.o
  CC [M]  /tmp/modconfig-lEXylP/vmblock-only/linux/control.o
  CC [M]  /tmp/modconfig-lEXylP/vmblock-only/linux/dentry.o
  CC [M]  /tmp/modconfig-lEXylP/vmblock-only/linux/file.o
/tmp/modconfig-lEXylP/vmblock-only/linux/dentry.c:38:4: warning: initialization from incompatible pointer type [enabled by default]
/tmp/modconfig-lEXylP/vmblock-only/linux/dentry.c:38:4: warning: (near initialization for ‘LinkDentryOps.d_revalidate’) [enabled by default]
/tmp/modconfig-lEXylP/vmblock-only/linux/dentry.c: In function ‘DentryOpRevalidate’:
/tmp/modconfig-lEXylP/vmblock-only/linux/dentry.c:104:7: warning: passing argument 2 of ‘actualDentry->d_op->d_revalidate’ makes integer from pointer without a cast [enabled by default]
/tmp/modconfig-lEXylP/vmblock-only/linux/dentry.c:104:7: note: expected ‘unsigned int’ but argument is of type ‘struct nameidata *’
/tmp/modconfig-lEXylP/vmblock-only/linux/control.c: In function ‘SetupProcDevice’:
/tmp/modconfig-lEXylP/vmblock-only/linux/control.c:211:4: error: implicit declaration of function ‘create_proc_entry’ [-Werror=implicit-function-declaration]
/tmp/modconfig-lEXylP/vmblock-only/linux/control.c:211:21: warning: assignment makes pointer from integer without a cast [enabled by default]
/tmp/modconfig-lEXylP/vmblock-only/linux/control.c:221:20: error: dereferencing pointer to incomplete type
/tmp/modconfig-lEXylP/vmblock-only/linux/control.c: In function ‘ExecuteBlockOp’:
/tmp/modconfig-lEXylP/vmblock-only/linux/control.c:285:9: warning: assignment from incompatible pointer type [enabled by default]
/tmp/modconfig-lEXylP/vmblock-only/linux/control.c:296:4: warning: passing argument 1 of ‘putname’ from incompatible pointer type [enabled by default]
In file included from include/linux/proc_fs.h:8:0,
                 from /tmp/modconfig-lEXylP/vmblock-only/linux/control.c:28:
include/linux/fs.h:2042:13: note: expected ‘struct filename *’ but argument is of type ‘char *’
cc1: some warnings being treated as errors
make[2]: *** [/tmp/modconfig-lEXylP/vmblock-only/linux/control.o] Error 1
make[2]: *** Waiting for unfinished jobs....
Someone else has already written the patch for vmnet. You can find the patch here. On the other hand, the fix for vmblock is actually pretty simple. In case anyone needs it, here's a patch I've written.

Download: vmblock.3.10.patch
diff -r -u a/linux/control.c b/linux/control.c
--- a/linux/control.c 2013-02-26 19:17:29.000000000 +1100
+++ b/linux/control.c 2013-07-02 16:09:10.000000000 +1000
@@ -208,17 +208,18 @@
    VMBlockSetProcEntryOwner(controlProcMountpoint);
 
    /* Create /proc/fs/vmblock/dev */
-   controlProcEntry = create_proc_entry(VMBLOCK_CONTROL_DEVNAME,
+   /*controlProcEntry = create_proc_entry(VMBLOCK_CONTROL_DEVNAME,
                                         VMBLOCK_CONTROL_MODE,
-                                        controlProcDirEntry);
-   if (!controlProcEntry) {
+                                        controlProcDirEntry);*/
+   controlProcEntry = proc_create(VMBLOCK_CONTROL_DEVNAME, VMBLOCK_CONTROL_MODE, controlProcDirEntry, &ControlFileOps);
+   if (controlProcEntry == NULL) {
       Warning("SetupProcDevice: could not create " VMBLOCK_DEVICE "\n");
       remove_proc_entry(VMBLOCK_CONTROL_MOUNTPOINT, controlProcDirEntry);
       remove_proc_entry(VMBLOCK_CONTROL_PROC_DIRNAME, NULL);
       return -EINVAL;
    }
 
-   controlProcEntry->proc_fops = &ControlFileOps;
+   /* controlProcEntry->proc_fops = &ControlFileOps; */
    return 0;
 }
 
@@ -293,7 +294,7 @@
 
    retval = i < 0 ? -EINVAL : blockOp(name, blocker);
 
-   putname(name);
+   __putname(name);
 
    return retval;
 }
Extract both tarballs (/usr/lib/vmware/modules/source/vmnet.tar and /usr/lib/vmware/modules/source/vmblock.tar) and apply the patches accordingly. Then, convert them back to tarballs before replacing the existing ones (you might want to make a backup just in case). Run the following and everything should now compile properly.:
sudo vmware-modconfig --console --install-all

Comments

  1. Nice. Had to remove the putname(name) section of the patch on gentoo, but worked a treat.

    ReplyDelete
  2. Me as well!!!

    Worked for Fedora 19 and VMware Workstation.

    Thank you so much.

    Best Regards from Germany
    BJ

    ReplyDelete
  3. How can I apply the patch ?

    ReplyDelete
    Replies
    1. I'll assume you have both the vmnet and vmblock patch files downloaded to your current directory.

      $ cp /usr/lib/vmware/modules/source/vmblock.tar ./vmblock.orig.tar
      $ cp /usr/lib/vmware/modules/source/vmnet.tar ./vmnet.orig.tar
      $ tar -xf ./vmblock.orig.tar
      $ tar -xf ./vmnet.orig.tar
      $ pushd ./vmblock-only && patch -p1 < ../vmblock.3.10.patch && popd
      $ pushd ./vmnet-only && patch -p1 < ../procfs.patch && popd
      $ tar -cf ./vmblock.tar ./vmblock-only
      $ tar -cf ./vmnet.tar ./vmnet-only
      $ sudo mv /usr/lib/vmware/modules/source/{vmnet.tar,vmnet.orig.tar}
      $ sudo mv /usr/lib/vmware/modules/source/{vmblock.tar,vmblock.orig.tar}
      $ sudo cp ./vmblock.tar /usr/lib/vmware/modules/source/
      $ sudo cp ./vmnet.tar /usr/lib/vmware/modules/source/
      $ sudo vmware-modconfig --console --install-all

      Delete
  4. Thank you Ricky Wong! You saved me from having to reinvent the wheel & allowed me to simply cut & paste each command (I do understand what they are doing, but it is good to be lazy sometimes).

    This worked perfectly on Fedora Core 19 with kernel 3.10.5-201.fc19.x86_64

    ReplyDelete
  5. THANK YOU SO MUCH! Still learning Fedora/Linux but needed VMW Workstation on the corporate laptop to run the corporate image. You just save me from having to give up on Fedora, thank you Ricky Wong!

    Fedora core 19 3.10.9-200.fc19.x86_64

    ReplyDelete
  6. Why don't you people just run Virtualbox? You don't have to patch it to get it to work.

    ReplyDelete
    Replies
    1. Virtual Box cant convert the snapshots.. Try working in an enterprise.

      Delete
  7. I have a similar problem with Workstation10.
    Do a patch exist for WS10?

    ReplyDelete
  8. I applied the 2 patches to WS9.02; it compiled fine and installed OK.
    But I got this starting vmware:
    *****************
    filename: /lib/modules/3.10.24-desktop-2.mga3/misc/vmmon.ko
    supported: external
    license: GPL v2
    description: VMware Virtual Machine Monitor.
    author: VMware, Inc.
    srcversion: 720B99362854B538D7E9A9A
    depends:
    vermagic: 3.10.24-desktop-2.mga3 SMP mod_unload modversions
    PANIC /build/mts/release/bora-1031769/bora/lib/unicode/unicodeCommon.c:330
    Abandon
    ***********************
    Any idea?

    ReplyDelete
  9. Thank you Ricky.
    Everything is fine now.
    Can the patches be applied to Workstaton10?

    ReplyDelete
    Replies
    1. I'm not entirely sure, since I'm still using WS9 (in conjunction with Linux 3.13).
      According to the arch linux wiki entry on vmware, WS10 should work with any kernel up to 3.12 without any patches.

      Delete

Post a Comment