SPI API Legato Tutorial dead end?

Hey guys,

I’ve been working to get SPI communicating to an MCP3008 (8-channel ADC) and am really struggling.

I have followed the instructions on Setup SPI on the Legato webpage: http://legato.io/legato-docs/latest/howToSPI.html and when I try to do the very last step, app start spisvc
I get “Application spisvc is not installed”. I’m wondering if the steps in the instructions are perhaps not complete? See screenshot attached to see the logs.

I also had to reference a MangOH forum post when following the Legato ‘howToSPI’ steps when my KO file originally wouldn’t compile, I had the exact same problems as the gentleman who wrote the post. SPI on mangOH Green.

I then aborted trying to use the Legato built-in SPI API and tried using the SpiService and SpiTest demo code in github https://github.com/mangOH/SpiTest/blob/master/spiTest.adef. It looks like the SpiTest code uses the MuxCtrlService… Is using the MuxCtrlService required on the MangOH red’s IOT0 SPI pins? Or will this not be required if I can get the built-in legato spisvc working?

My most recent attempt to send/receive data over SPI has been using the SPI interface API at ${LEGATO_ROOT}/interfaces/le_spi.api, which I figured would be the most promising… But I have been out of luck on that too.

Overall I’m now completely lost on how I would send a basic SPI message over the IOT0 SPI pins on the MangOH Red.

For reference, my forked version of the SPI code can be found here: https://github.com/coastalbrandon/SpiTest

The code has been intended to use the SpiService provided in the Legato framework at the following location ${LEGATO_ROOT}/interfaces/le_spi.api as mentioned in my previous post. I still am assuming this is the SPI api that I should be using.

If anyone has a moment to review my github fork I would really appreciate it. The application compiles and I can run it, but I don’t even see the first LE_INFO output of ===========> SPI application has started… Which perhaps should be a sign.

Are you using the VM or the getting started instructions to setup your computer?
If so, we will do a small update to the sdef tomorrow that should allow the spisvc to be prebuilt.

I’m using the VM.

Thanks!

Can you update your git and follow the instructions:

Thanks! I managed to get my SPI connection working a couple of hours ago - it brought me great pain… But I definitely learned a lot about the legato file structure over the past 24 hours!

I’ll keep the GIT around in case anyone else wants to expand to 8 analog inputs on the mangoh red with an MCP3008.

1 Like

Hello Asyal,

I’m using a Mangoh green and wp8548…

I’m having the same problem as coastalbrandon, and also when I try to do the very last step, app start spisvc I get “Application spisvc is not installed”.

I’m using the VM provided in the mangoh green getting started.

Can you help me with that?

If you wouldn’t mind, could you clarify something?:
-> There is spiService running in the WP8548 legato 16.10.4, why do I have to setup it?

Kind regards,

Hello coastalbrandon,

I think I have the same problem you had.
I wanted to execute the same code sample for spi application but i didn’t have any output (even not ===========> SPI application has started").
For a very first step I figured out that, it’s caused from the linking to le_spi.api:
– I omit all the code inside the COMPONENT_INIT and only maintain the following instruction LE_INFO("===========> SPI application has started");
– If i compiled with the spi API (requires + bindings), It doesn’t output anything when executing.
– If I suppress the link to spi API, I get my output.

Does this problem seem to be familiar to you?

Thanks,

Hey @Sdik91,

We’ve tried many different things with our SPI setup with varying success, but I think we finally have the magic combination. Our use case involved reading from an MCP3004, so we’ve tried:

  1. Using the spiService
  2. Using a kernel driver
  3. Requiring the spiLibrary component instead of using a separate service

Ultimately approach 1 and 3 worked, but spiService has reliability issues related to sandboxing and how the drivers are loaded. Somewhere around Legato 18.05.0 the SPI service was changed to “auto start” using some scripts, but I never got this working on the WP85. I’ve been running a forked version of spiService which removes sandbox mode for the sake of stability.

This also required modifying /etc/modules. spiService depends on /dev/spidevX.Y being available, which means the spidev kernel module must be loaded. So far adding spidev to /etc/module (e.g echo "spidev" >> /etc/modules) seems to work OK, but it’s another setup step I’d prefer to avoid.

The spiService is very useful if you’re sharing the SPI bus between a few apps or using it with an IoT expansion card, but if your SPI bus is being used in only one app and you aren’t using an expander, I think the spiLibrary component is a better choice. It’s one less service to run and one less interprocess API for no real compromise.

I put a quick repository together (https://github.com/brnkl/mangoh-mcp3004) with our code to read from the MCP3004, but it’s still missing a sample code, a Makefile, and a readme. I’ll add these details in the coming days.