SPI after startup


In the new Framework 16.10.1 on the WP8548. I have managed to build the spisvc.ko file, but on startup, the spiService is not running and I have to install the spidev,spisvc.ko manually and also start the spiService App. Is there a way to have it start automatically, as my App is stalling with the message, “missing binding: .App.le_spi -> spiService.le_spi”.

I have written a script to install the spi and start the spiService, but the App cant execute the script, as it is halted before getting to the code because of the missing binding.


Have you modified your system definition file (sdef) to refer to the module definition file (mdef) for the spisvc module? If you do that, then the spisvc module should be loaded when the legato application framework starts.


I was experiencing the same problem as mouse365. I was trying to solve it via scripts or other ways.

It would be useful if SPI documentation is updated in order to know how to make spiService start automatically.
It would also be useful if this drivers and kernel modules were alrady installed in the Frameworks.

We used to use OPEN AT platform where all hardware features were ready to use via APIs. As those modems are discontinued, we are migrating to Legato and WP85. We think that this new concept is awesome and really powerful, but documentation is not as good as OPEN AT was. I´m really new working with Legato, but it is being difficult to work with hardware features as SPI, I2C…etc.


Following this thread again, once I´m getting closer to knowing this platform.

I have created a "System Project’, and as dfrey said, I have attached to my project spisvc.ko and spisvc.mdef.

spisvc.mdef looks like this:


Then in Mysystem.sdef I´ve got a section like this:

///ds/workspace/RecuperacionSystem/spisvc // I have also tested like this, but with the same result.

The thing is that spiService is not starting.

I´m missing something?


Hello Luis,

Please look my last post (Sierra_spi.c missing in Legato-Dist-Source-mdm9x15-SWI9X15Y_07.11.21.00).

The sierra_spi driver has been removed from Linux bsp sources.

Best regards,


It’s strange that spiService is not starting automatically. You can see in the adef that start is set to auto


Hello Sylvain and dfrey

I can really use spiService by starting it manually and works perfect. In order to do it, I have to install spisvc.ko driver with insmod command. Once I have done this, “spidev0.0” is created inside / dev. Then I can start spiService manually and start without any error.

The thing is that I need to start it automatically. As dfrey said, I realized that it was set to auto in spiService project. So I need a way to install spisvc.ko when Legato starts so that “spidev0.0” is created. The way I read I had to do it via sdef and mdef files.

I decided to create my own system where I included spisvc.ko and its mdef file and I edited the sdef file of my system to point to this kernel module. But spiService is not starting and the error is “Can’t find spidev0.0”

Best regards


The /dev/spidev0.0 device should be created when the spisvc.ko kernel module is loaded. Because you reference the mdef from your sdef, this should be happening when legato starts (before any legato apps start). Maybe someone else can provide some suggestions. It seems like you have followed the correct steps.


Thanks dfrey,

I will keep on trying on this issue. If I make some progress, I´ll post it.


I have added spisvc and spidrv into the kernel with a patch to run a null codec for audio building a all in one cwe image it’s not terribly complicated .


If you can give me some advice, It would be very helpful.

I would love to achive it via mdef and sdef because it is the way is documented, but I`d like to know other ways to do it.
It rings a bell that cwe is the extension for updating firmware files.


Add the spisvc code to the kernel tree in yocto


add spisvc/spidev [depending on config selected]

select spidev/spisvc in drivers/spi
spisvc must be sleected a module spidev can be built in

bitbake linux-yocto -c menuconfig

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 495b164..07cc6d1 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -572,6 +572,14 @@ config SPI_SPIDEV
 	  Note that this application programming interface is EXPERIMENTAL
 	  and hence SUBJECT TO CHANGE WITHOUT NOTICE while it stabilizes.
+config SPI_SPISVC
+	tristate "User mode SPI device driver support (msm)"
+	help
+	  This supports user mode SPI protocol drivers.
+	  Note that this application programming interface is EXPERIMENTAL
+	  and hence SUBJECT TO CHANGE WITHOUT NOTICE while it stabilizes.
 config SPI_TLE62X0
 	tristate "Infineon TLE62X0 (for power switching)"
 	depends on SYSFS
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 7b9875c..322e31a 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -8,6 +8,7 @@ ccflags-$(CONFIG_SPI_DEBUG) := -DDEBUG
 # config declarations into driver model code
 obj-$(CONFIG_SPI_MASTER)		+= spi.o
 obj-$(CONFIG_SPI_SPIDEV)		+= spidev.o
+obj-$(CONFIG_SPI_SPISVC)		+= spisvc.o
 # SPI master controller drivers (bus)
 obj-$(CONFIG_SPI_ALTERA)		+= spi-altera.o
diff --git a/drivers/spi/spisvc.c b/drivers/spi/spisvc.c
new file mode 100644
index 0000000..021e056
--- /dev/null
+++ b/drivers/spi/spisvc.c
@@ -0,0 +1,63 @@
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ *
+ * Copyright (C) 2016 Sierra Wireless Inc.
+ */
+#define MOD_DESC "Spidev creation module"
+MODULE_AUTHOR("Sierra Wireless, Inc.");
+static struct spi_device *spidev;
+static __init int spisvc_init(void)
+	struct spi_master *master;
+	struct spi_board_info board = {
+		.modalias = "spidev",
+		.max_speed_hz = 15058800,
+		.mode = SPI_MODE_3,
+		.platform_data = NULL,
+		.bus_num = 0,
+		.chip_select = 0,
+		.irq = 0,
+	};
+	master = spi_busnum_to_master(0);
+	if (!master) {
+		pr_err("No master for SPI bus 0.\n");
+		return -ENODEV;
+	}
+	spidev = spi_new_device(master, &board);
+	if (!spidev) {
+		pr_err("Error creating device '%s'\n", board.modalias);
+		return -ENODEV;
+	}
+	return 0;
+static __exit void spisvc_exit(void)
+	if (spidev)
+		spi_unregister_device(spidev);


Lots of thanks gregnietsky!!.

Let`s see if I make some progress


You will need to look at the yocto docs and how to build it
run make in the build root to build a clean image first then …

to use bitbake you need to set up your enviroment first as follows once you have saved the kernel config a make will build the images as expected …

. ./poky/oe-init-build-env
cd …/build_bin


The issue appears to be with the systemPackaging rules that is part of the mkTools which creates mksys. It only looks at $LEGATO_ROOT/build/$target/system/modules for any *.ko files during staging, even though it does put any found in the project from a ‘kernelModules’ section in the *.sdef file into the project build directory. This still appears to be that case in legato-af source for github as of now. The following patch will also check for modules in the project build directory and copy them to staging. do a ‘make tools’ in the root of your legato framework after patching then rebuild your project with mksys as usual.

diff --git a/framework/tools/mkTools/buildScriptGenerator/systemBuildScript.cpp 
index 56304f4..467bd40 100644
--- a/framework/tools/mkTools/buildScriptGenerator/systemBuildScript.cpp
+++ b/framework/tools/mkTools/buildScriptGenerator/systemBuildScript.cpp
@@ -71,13 +71,19 @@ static void GenerateSystemBuildRules
     "            find $$LEGATO_ROOT/build/$target/framework/lib/* -type d -prun
                        " \\( -type f -o -type l \\) -print | xargs cp -P -t $st
-    // Create modules directory and copy kernel modules into it
+    // Create modules directory and copy framework kernel modules into it
     "            mkdir -p $stagingDir/modules && $\n"
     "            if [ -d $$LEGATO_ROOT/build/$target/system/modules ] ; then $\
     "                find $$LEGATO_ROOT/build/$target/system/modules/*/*.ko -pr
                           "| xargs cp -P -t $stagingDir/modules ; $\n"
     "            fi && $\n"
+    // copy project kernel modules into it
+    "            if [ -d $builddir/modules ] ; then $\n"
+    "                find $builddir/modules/*/*.ko -print"
+                          "| xargs cp -P -t $stagingDir/modules ; $\n"
+    "            fi && $\n"
     // Create an apps directory for the symlinks to the apps.
     "            mkdir -p $stagingDir/apps && $\n";



Was there ever a solution found not involving modifying the yocto tree? I found this thread after creating my own: Starting SPI automatically and I feel like I have the same kind of issue.

I am using a mangOH Red with WP8548.