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.11-rc1 (vmware 9)

Linux 3.11-rc1 was released a few days ago. With it comes a kernel-level API change related to VFS. Specifically, struct file_operations no longer contains the function pointer readdir and vfs_readdir() which was defined in fs/readdir.c is now gone. They are both superseded by iterate and iterate_dir() respectively. Unfortunately, these changes broke the compilation of the vmblock fs module.

So, here is a simple patch I've written for anyone who is interested. Note that you also have to apply the vmblock patch for linux 3.10 if you haven't already. Otherwise, the compilation would fail.

Download: vmblock.3.11.patch
diff --git a/linux/file.c b/linux/file.c
index d7ac1f6..5499169 100644
--- a/linux/file.c
+++ b/linux/file.c
@@ -38,46 +38,6 @@ typedef u64 inode_num_t;
 typedef ino_t inode_num_t;
 #endif
 
-/* Specifically for our filldir_t callback */
-typedef struct FilldirInfo {
-   filldir_t filldir;
-   void *dirent;
-} FilldirInfo;
-
-
-/*
- *----------------------------------------------------------------------------
- *
- * Filldir --
- *
- *    Callback function for readdir that we use in place of the one provided.
- *    This allows us to specify that each dentry is a symlink, but pass through
- *    everything else to the original filldir function.
- *
- * Results:
- *    Original filldir's return value.
- *
- * Side effects:
- *    Directory information gets copied to user's buffer.
- *
- *----------------------------------------------------------------------------
- */
-
-static int
-Filldir(void *buf,              // IN: Dirent buffer passed from FileOpReaddir
-        const char *name,       // IN: Dirent name
-        int namelen,            // IN: len of dirent's name
-        loff_t offset,          // IN: Offset
-        inode_num_t ino,        // IN: Inode number of dirent
-        unsigned int d_type)    // IN: Type of file
-{
-   FilldirInfo *info = buf;
-
-   /* Specify DT_LNK regardless */
-   return info->filldir(info->dirent, name, namelen, offset, ino, DT_LNK);
-}
-
-
 /* File operations */
 
 /*
@@ -166,11 +126,10 @@ FileOpOpen(struct inode *inode,  // IN
 
 static int
 FileOpReaddir(struct file *file,  // IN
-              void *dirent,       // IN
-              filldir_t filldir)  // IN
+              struct dir_context *ctx)  // IN
 {
    int ret;
-   FilldirInfo info;
+
    struct file *actualFile;
 
    if (!file) {
@@ -184,12 +143,10 @@ FileOpReaddir(struct file *file,  // IN
       return -EINVAL;
    }
 
-   info.filldir = filldir;
-   info.dirent = dirent;
-
-   actualFile->f_pos = file->f_pos;
-   ret = vfs_readdir(actualFile, Filldir, &info);
-   file->f_pos = actualFile->f_pos;
+   /* Ricky Wong Yung Fei:
+    * Manipulation of pos is now handled internally by iterate_dir().
+    */
+   ret = iterate_dir(actualFile, ctx);
 
    return ret;
 }
@@ -237,7 +194,7 @@ FileOpRelease(struct inode *inode, // IN
 
 
 struct file_operations RootFileOps = {
-   .readdir = FileOpReaddir,
+   .iterate = FileOpReaddir,
    .open    = FileOpOpen,
    .release = FileOpRelease,
 };
As usual, apply the patch and do:
sudo vmware-modconfig --console --install-all
Verification to show that the patch works properly:
ricky@ci5-Studio-XPS-1647:~$ sudo modprobe -v vmblock
insmod /lib/modules/3.11.0-rc1+/misc/vmblock.ko 
ricky@ci5-Studio-XPS-1647:~$ echo "testing1" > /tmp/VMwareDnD/testing1
ricky@ci5-Studio-XPS-1647:~$ mkdir -p /tmp/VMwareDnD/testing2/testing3
ricky@ci5-Studio-XPS-1647:~$ sudo mount -t vmblock none /proc/fs/vmblock/mountPoint
ricky@ci5-Studio-XPS-1647:~$ ls -al /proc/fs/vmblock/mountPoint/
total 0
dr-xr-xr-x 1 root root 0 Jan  1  1970 .
dr-xr-xr-x 3 root root 0 Jul 17 00:38 ..
lrwxrwxrwx 1 root root 0 Jul 17 00:38 testing1 -> /tmp/VMwareDnD/testing1
lrwxrwxrwx 1 root root 0 Jul 17 00:38 testing2 -> /tmp/VMwareDnD/testing2

Comments

  1. Nice. This is what worked for me:

    cd /tmp
    curl -O http://pkgbuild.com/git/aur-mirror.git/plain/vmware-patch/vmblock-9.0.2-5.0.2-3.10.patch
    curl -O http://pkgbuild.com/git/aur-mirror.git/plain/vmware-patch/vmnet-9.0.2-5.0.2-3.10.patch
    wget https://sites.google.com/site/mysticalzerotmp/vmblock.3.11.patch
    cd /usr/lib/vmware/modules/source
    tar -xvf vmblock.tar
    tar -xvf vmnet.tar
    patch -p0 -i /tmp/vmblock-9.0.2-5.0.2-3.10.patch
    patch -p0 -i /tmp/vmnet-9.0.2-5.0.2-3.10.patch
    cd vmblock-only
    patch -p1 -i /tmp/vmblock.3.11.patch
    cd ..
    tar -cf vmblock.tar vmblock-only
    tar -cf vmnet.tar vmnet-only
    rm -r vmblock-only
    rm -r vmnet-only
    vmware-modconfig --console --install-all

    ReplyDelete
    Replies
    1. Thanks, works like a charm on Ubuntu 13.04 with kernel 3.11

      Delete
  2. Really nice shell script ^ works on fedora rawhide

    ReplyDelete
  3. Another API change in 3.12. See here for my patch: http://dominator008.com/shootingrange/2013/10/03/vmware-9-0-2-vmblock-patch-for-linux-kernel-3-12/

    ReplyDelete
  4. Why the hell so many API changes?

    ReplyDelete
  5. Thanks a bunch!

    ReplyDelete

Post a Comment