Difference between revisions of "Mikrobus"

From eLinux.org
Jump to: navigation, search
m (Update Mikrobus Driver Approach)
(12 intermediate revisions by the same user not shown)
Line 6: Line 6:
  
 
=== Device tree overlays loaded at boot time ===
 
=== Device tree overlays loaded at boot time ===
Today, there is no mainline solution for enabling mikroBUS add-on boards at run-time, so they must all be configured at boot-time with device-tree.
+
Today, there is no mainline solution for enabling mikroBUS add-on boards at run-time, so they must all be configured at boot-time with device trees<ref group="definitions">Definition of device tree needed</ref>.
  
 
Instructions for PocketBeagle: https://github.com/beagleboard/pocketbeagle/wiki/Click-boards%E2%84%A2
 
Instructions for PocketBeagle: https://github.com/beagleboard/pocketbeagle/wiki/Click-boards%E2%84%A2
Line 12: Line 12:
 
Example overlay: https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/PB-I2C2-MPU-9DOF-CLICK.dts
 
Example overlay: https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/PB-I2C2-MPU-9DOF-CLICK.dts
  
There are some out-of-tree mechanisms for loading device-tree overlay fragments. TODO: Need reference to DTBO configfs patch. This patch doesn't apply after 4.14 and is not likely to be accepted in mainline. Mainline doesn't want arbitrary device-tree fragments, but there is a chance that this could be considered a "development-only" patch if this is rebased. The solution would allow run-time loading, but would not be automatic and requires authoring of overlay fragments specific to every add-on board, every Linux platform and every mikroBUS socket.
+
This is the primary mechanism for enumerating device drivers<ref group="definitions">Definition of device drivers needed</ref> for mikroBUS add-on boards today. It suffers from the need to maintain a large out-of-tree database for which you'd need an overlay for every mikroBUS add-on board for every Linux system for every mikroBUS socket on that system. Multiplying 1,000 Click boards by the number of BeagleBoard.org boards by the number of sockets supported on each of those boards ends up being a LOT of device tree overlay fragments.
 +
 
 +
Further, the application of those fragments is rather error prone and can even result in preventing a system from booting.
 +
 
 +
==== Run-time device tree overlays ====
 +
There are some out-of-tree mechanisms<ref>[https://lore.kernel.org/patchwork/patch/511853/ OF: DT-Overlay configfs interface (v2)]</ref> for loading device-tree overlay fragments via ConfigFS.
 +
 
 +
[https://github.com/beagleboard/linux/commit/c402adbf1ea4443462621a7ff5062b93dbd1d618 This patch] doesn't apply after 4.14 and is not likely to be accepted in mainline. Mainline doesn't want arbitrary device-tree fragments<ref>Citation needed</ref>, but there is a chance that this could be considered a "development-only" patch if this is rebased. The solution would allow run-time loading, but would not be automatic and requires authoring of overlay fragments specific to every add-on board, every Linux platform and every mikroBUS socket.
  
 
=== Using Greybus simulator to enable software hotplug support ===
 
=== Using Greybus simulator to enable software hotplug support ===
This requires running the Greybus simulator, [https://github.com/projectara/gbsim gbsim] . Instructions for setting up gbsim and more information can be found [https://github.com/vaishnav98/gbsim/wiki/Beagleboard-GSoC-'19:--Clickboard-Support-Under-Greybus here]. This method uses Greybus simulator to load a manifest blob to kernel greybus driver where the virtual interfaces(SPI/I2C/other) are created and gbsim manages the transfers between the physical bus/gpio/interrupt and the virtual greybus interface.
+
It is possible to enumerate some device drivers for mikroBUS add-on boards by running the Greybus simulator, [https://github.com/projectara/gbsim gbsim]. Instructions for setting up gbsim and more information can be found [https://github.com/vaishnav98/gbsim/wiki/Beagleboard-GSoC-'19:--Clickboard-Support-Under-Greybus in a wiki write-up on a GSoC project]. This method uses Greybus simulator to load a manifest blob to the kernel greybus driver where the virtual interfaces(SPI/I2C/other) are created.
 +
 
 +
gbsim manages the transfers between the physical bus/gpio/interrupt and the virtual Greybus interface. Having a userspace application, gbsim, in the middle of the transactions has a performance and security impact.
  
This approach requires additional platform data for instantiating Click Devices with platform data requirements like reset/interrupt-gpio/other named-gpio, thus the approach needs more refinements to tackle the issues of instantiating devices with additional platform data requirements, a few approaches to solve this problem is discussed [https://elinux.org/BeagleBoard/Mikrobus_Support here]. This approach has an added advantage of using different transports which makes it ideal for [https://www.youtube.com/watch?v=7H50pv-4YXw IoT Applications].
+
This approach requires additional platform data<ref group="definitions">[https://www.kernel.org/doc/htmldocs/writing_musb_glue_layer/device-platform-data.html Device platform data] is data describing the hardware capabilities of your controller hardware</ref> for instantiating device drivers for mikroBUS add-on boards with platform data requirements like reset, interrupt-gpio, and other named-gpio, thus the approach needs more refinements to tackle the issues of instantiating devices with additional platform data requirements. A few approaches to solve this problem are discussed [https://elinux.org/BeagleBoard/Mikrobus_Support here].
 +
 
 +
Using Greybus to enumerate drivers for mikroBUS add-on boards has an added advantage of using different transports<ref group="definitions">Need definition of transport</ref> which makes it ideal for IoT applications<ref>[https://www.youtube.com/watch?v=7H50pv-4YXw Using Greybus for IoT]</ref>. A transport could be a wired or wireless network, in addition to more flexible embedded busses like Unipro.
  
 
== Implementation of a mikroBUS socket on an embedded Linux system ==
 
== Implementation of a mikroBUS socket on an embedded Linux system ==
Line 26: Line 37:
  
 
=== Creation of a mikroBUS bus driver in the Linux kernel ===
 
=== Creation of a mikroBUS bus driver in the Linux kernel ===
This approach does not involve the use of greybus directly but uses the greybus manifests for providing the platform data, it is actually a combination of the [https://elixir.bootlin.com/linux/v4.9.17/source/drivers/staging/greybus/manifest.c#L454 Greybus manifest parsing logic] combined with the working of [https://github.com/beagleboard/linux/blob/3.8/drivers/misc/cape/beaglebone/capemgr.c Bone Cape Manager] used in the previous BB kernels, the Cape Manager used to load the data for a cape from the Device Tree whereas this bus driver takes the data from the manifest blob passed via the SysFS interface.The Mikrobus port information for the device is parsed from the Device Tree(this information only account for the port information and does not have any click specific information).
+
This approach does not involve the use of greybus directly but uses the greybus manifests for providing the platform data, it is actually a combination of the [https://elixir.bootlin.com/linux/v4.9.17/source/drivers/staging/greybus/manifest.c#L454 Greybus manifest parsing logic] combined with the working of [https://github.com/beagleboard/linux/blob/3.8/drivers/misc/cape/beaglebone/capemgr.c Bone Cape Manager] used in the previous BB kernels, the Cape Manager used to load the data for a cape from the Device Tree whereas this bus driver<ref group="definitions">Definition of bus driver needed</ref> takes the data from the manifest blob passed via the SysFS interface.The Mikrobus port information for the device is parsed from the Device Tree(this information only account for the port information and does not have any click specific information).
 +
 
 
== Improving the mikroBUS standard for better Linux support ==
 
== Improving the mikroBUS standard for better Linux support ==
  
 
=== Identifier ===
 
=== Identifier ===
 +
Adding an identifier<ref group="definitions">Definition of identifier needed</ref> would provide a way to load the device drivers for a mikroBUS add-on board without the need for manual configuration. By fetching the identifier in the mikroBUS bus driver probe<ref group="definitions">Definition of probe needed</ref> function, would enable that function to call the probe function in the various device drivers.
 +
 
==== Proposal #1: Use Greybus Manifest binaries ====
 
==== Proposal #1: Use Greybus Manifest binaries ====
 
* Module vendor specified separately from driver usage
 
* Module vendor specified separately from driver usage
 
* Possibility of using existing driver names for invocation
 
* Possibility of using existing driver names for invocation
 +
 
==== Proposal #2: Use simple string identifiers ====
 
==== Proposal #2: Use simple string identifiers ====
 
* Requires table to be kept in kernel
 
* Requires table to be kept in kernel
Line 39: Line 54:
 
=== Specifics on power function ===
 
=== Specifics on power function ===
 
The direction and accommodations related to the power pins aren't as specific in the mikroBus standard as with Feather.
 
The direction and accommodations related to the power pins aren't as specific in the mikroBus standard as with Feather.
 +
 +
== Usage of improved mikroBUS support in Linux and mikroBUS standard ==
 +
Assuming all of the suggestions above are implemented, what would the resulting usage be?
 +
 +
=== Adding a mikroBUS socket to your Linux system ===
 +
TODO: Describe how to add a device tree definition for mikroBUS sockets to new Linux systems.
 +
 +
=== Adding support for a mikroBUS add-on board to the Linux kernel ===
 +
TODO: Describe how to create device drivers and identifiers for new add-on boards.
  
 
== Comparisons to other popular embedded add-on form-factors ==
 
== Comparisons to other popular embedded add-on form-factors ==
Line 60: Line 84:
 
=== Why should mikroBUS be a bus in the kernel even if these other interfaces aren't? ===
 
=== Why should mikroBUS be a bus in the kernel even if these other interfaces aren't? ===
  
* It's an open standard
+
* mikroBUS is simple, not requiring the need to overlay arbitrary device trees like Capes or other excessively flexible interfaces defined arbitrary collections of microcontroller pins.
* Over 750+ Click add-on boards ranging from wireless connectivity clicks to Human Machine Interface clicks, of which more than 100+ clicks has already support in the linux kernel.
+
* mikroBUS a free standard and not an ad-hoc one.
* Over 140+ Development boards [https://www.mikroe.com/blog/development-boards-that-support-mikrobus supported.]
+
* Over 750+ Click add-on boards ranging from wireless connectivity clicks to Human Machine Interface clicks, of which more than 100+ clicks already have support in the Linux kernel.
 +
* Over 140+ Development boards supported<ref>[https://www.mikroe.com/blog/development-boards-that-support-mikrobus Development boards that support mikroBUS]</ref>.
  
 
=== Why aren't we opening pandora's box by adding this as a bus in the kernel? ===
 
=== Why aren't we opening pandora's box by adding this as a bus in the kernel? ===
  
 
== Definitions ==
 
== Definitions ==
* Platform data
+
<references group="definitions" />
* Device driver
+
 
* Bus driver
+
== References ==
* Probe
+
<references />
* Identifier
 
* Device tree
 

Revision as of 14:52, 5 April 2020

mikroBUS is a standard specification by MikroElektronika that can be freely used by anyone following the guidelines. It includes SPI, I2C, UART, PWM, ADC, reset, interrupt, and power (3.3V and 5V) connections to common embedded peripherals.

This page is meant to foster discussion within the embedded Linux community on usage of mikroBUS compatible add-on boards, adding mikroBUS sockets to embedded Linux systems, and ways to improve both Linux support for mikroBUS and the mikroBUS standard.

Usage of mikroBUS compatible add-on boards today

Device tree overlays loaded at boot time

Today, there is no mainline solution for enabling mikroBUS add-on boards at run-time, so they must all be configured at boot-time with device trees[definitions 1].

Instructions for PocketBeagle: https://github.com/beagleboard/pocketbeagle/wiki/Click-boards%E2%84%A2

Example overlay: https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/PB-I2C2-MPU-9DOF-CLICK.dts

This is the primary mechanism for enumerating device drivers[definitions 2] for mikroBUS add-on boards today. It suffers from the need to maintain a large out-of-tree database for which you'd need an overlay for every mikroBUS add-on board for every Linux system for every mikroBUS socket on that system. Multiplying 1,000 Click boards by the number of BeagleBoard.org boards by the number of sockets supported on each of those boards ends up being a LOT of device tree overlay fragments.

Further, the application of those fragments is rather error prone and can even result in preventing a system from booting.

Run-time device tree overlays

There are some out-of-tree mechanisms[1] for loading device-tree overlay fragments via ConfigFS.

This patch doesn't apply after 4.14 and is not likely to be accepted in mainline. Mainline doesn't want arbitrary device-tree fragments[2], but there is a chance that this could be considered a "development-only" patch if this is rebased. The solution would allow run-time loading, but would not be automatic and requires authoring of overlay fragments specific to every add-on board, every Linux platform and every mikroBUS socket.

Using Greybus simulator to enable software hotplug support

It is possible to enumerate some device drivers for mikroBUS add-on boards by running the Greybus simulator, gbsim. Instructions for setting up gbsim and more information can be found in a wiki write-up on a GSoC project. This method uses Greybus simulator to load a manifest blob to the kernel greybus driver where the virtual interfaces(SPI/I2C/other) are created.

gbsim manages the transfers between the physical bus/gpio/interrupt and the virtual Greybus interface. Having a userspace application, gbsim, in the middle of the transactions has a performance and security impact.

This approach requires additional platform data[definitions 3] for instantiating device drivers for mikroBUS add-on boards with platform data requirements like reset, interrupt-gpio, and other named-gpio, thus the approach needs more refinements to tackle the issues of instantiating devices with additional platform data requirements. A few approaches to solve this problem are discussed here.

Using Greybus to enumerate drivers for mikroBUS add-on boards has an added advantage of using different transports[definitions 4] which makes it ideal for IoT applications[3]. A transport could be a wired or wireless network, in addition to more flexible embedded busses like Unipro.

Implementation of a mikroBUS socket on an embedded Linux system

Improving Linux support for mikroBUS

Motivation for supporting software hotplug

Creation of a mikroBUS bus driver in the Linux kernel

This approach does not involve the use of greybus directly but uses the greybus manifests for providing the platform data, it is actually a combination of the Greybus manifest parsing logic combined with the working of Bone Cape Manager used in the previous BB kernels, the Cape Manager used to load the data for a cape from the Device Tree whereas this bus driver[definitions 5] takes the data from the manifest blob passed via the SysFS interface.The Mikrobus port information for the device is parsed from the Device Tree(this information only account for the port information and does not have any click specific information).

Improving the mikroBUS standard for better Linux support

Identifier

Adding an identifier[definitions 6] would provide a way to load the device drivers for a mikroBUS add-on board without the need for manual configuration. By fetching the identifier in the mikroBUS bus driver probe[definitions 7] function, would enable that function to call the probe function in the various device drivers.

Proposal #1: Use Greybus Manifest binaries

  • Module vendor specified separately from driver usage
  • Possibility of using existing driver names for invocation

Proposal #2: Use simple string identifiers

  • Requires table to be kept in kernel
  • Fix-ups would be very direct and not "fix-ups" at all, since no driver specific information would be encoded

Specifics on power function

The direction and accommodations related to the power pins aren't as specific in the mikroBus standard as with Feather.

Usage of improved mikroBUS support in Linux and mikroBUS standard

Assuming all of the suggestions above are implemented, what would the resulting usage be?

Adding a mikroBUS socket to your Linux system

TODO: Describe how to add a device tree definition for mikroBUS sockets to new Linux systems.

Adding support for a mikroBUS add-on board to the Linux kernel

TODO: Describe how to create device drivers and identifiers for new add-on boards.

Comparisons to other popular embedded add-on form-factors

The purpose of this page is to advance the development of mikroBUS support in Linux. Some distractions may be introduced to either illustrate the effort cannot be sufficiently limited in scope to tackle or that focus should be elsewhere. I'm not assuming these would be introduced with any ill-will, they are just natural concerns that need to be addressed up-front.

Form-factor Size Comments
mikroBUS 1.0" x 1.125"/1.6"/2.25" Example
Feather/Wing 0.9" x 2.0" De-facto standard based on implementation pin-out. Could benefit from some of the efforts for mikroBUS support, but not as cleanly defined with a limited and focused scope. Not as easy to make an impact on the majority of existing designs.
Arduino/Shield XxY Too irregular to make useful as an embedded system bus.
BeagleBone/Cape XxY Far too flexible for a standard outside of the Beagle ecosystem.

Why should mikroBUS be a bus in the kernel even if these other interfaces aren't?

  • mikroBUS is simple, not requiring the need to overlay arbitrary device trees like Capes or other excessively flexible interfaces defined arbitrary collections of microcontroller pins.
  • mikroBUS a free standard and not an ad-hoc one.
  • Over 750+ Click add-on boards ranging from wireless connectivity clicks to Human Machine Interface clicks, of which more than 100+ clicks already have support in the Linux kernel.
  • Over 140+ Development boards supported[4].

Why aren't we opening pandora's box by adding this as a bus in the kernel?

Definitions

  1. Definition of device tree needed
  2. Definition of device drivers needed
  3. Device platform data is data describing the hardware capabilities of your controller hardware
  4. Need definition of transport
  5. Definition of bus driver needed
  6. Definition of identifier needed
  7. Definition of probe needed

References