If an assigned hardware resource changes either during application development or after development is finished (for example, the GPIO of a push button or the availability of a PWM) and the resources are hardcoded in your source code, you must edit the files and rebuild your applications for changes to take effect.
You can avoid this by using libdigiapix to define aliases for your interfaces in a configuration file.
In your application, you can then refer to the alias USER_BUTTON
instead of controller label mca-gpio
and line number 5 when requesting a GPIO.
If the hardware changes, the application code is still valid; when you change the value of the alias in the configuration file, it points to the new kernel number value.
Define your libdigiapix configuration file
The configuration file is /etc/libdigiapix.conf
.
You can define your aliases:
-
At runtime, by modifying the
/etc/libdigiapix.conf
file in the root file system of your device. See Configuration file syntax. -
At build time, by appending your own configuration files to the libdigiapix package. The recipe that builds this package is located inside the meta-digi layer,
meta-digi/meta-digi-dey/recipes-digi/libdigiapix/libdigiapix_git.bb
.
To create images that include your own configuration file, follow these steps:
-
Write the configuration file,
libdigiapix.conf
, for your hardware. See Configuration file syntax. -
Place it in your layer inside the directory
recipes-digi/libdigiapix/libdigiapix
. -
Create a
libdigiapix_%.bbappend
file inside the directoryrecipes-digi/libdigiapix
of your layer to extend the existing recipe file with new files.libdigiapix_%.bbappend
fileFILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:" SRC_URI:append = " \ file://libdigiapix.conf \ "
-
Build Digi Embedded Yocto as usual. You can:
-
Build the image. For example,
dey-image-qt
:$ bitbake dey-image-qt
See Build images and Update firmware.
-
Build a software update package. For example,
dey-image-qt-swu
:$ bitbake dey-image-qt-swu
Use these recipes or your own to create your firmware.
-
Configuration file syntax
Define the aliases for your device interfaces in your libdigiapix.conf
following format.
libdigiapix.conf
[board]
model = Digi International ConnectCore 6UL SBC.
[GPIO]
# USER LED
USER_LED = gpio1,23
# USER BUTTON
USER_BUTTON = mca-gpio,1
[I2C]
# I2C-1 on I2C board connector.
DEFAULT_I2C_BUS = 0
[SPI]
# SPI-1 on SPI board connector, slave 0.
DEFAULT_SPI = 0,0
[PWM]
# PWM4 on GPIO board connector (pin 11).
DEFAULT_PWM = 0,0
Board section
This is a mandatory section to identify your board. It must contain the following properties:
Name | Mandatory | Description | ||
---|---|---|---|---|
|
- |
Contains the absolute path to the file that contains the model of your board in its file system. Specify its value if it is different from the default value, |
||
|
The model to identify your hardware.
It should match the model in the configured
|
[board]
model = Digi International ConnectCore 93 Development Kit.
GPIO section
Optional section to identify GPIOs. The following two formats are valid:
Aliases for GPIO using controller label and line
It contains a list of the human-readable names associated with their corresponding GPIO controller name or label and line number. They must follow the format:
<alias> = <controller>,<line>
Where:
-
<alias>
is the human-readable name for the GPIO. -
<controller>
is the GPIO controller name or label. -
<line>
is the GPIO line number.
[GPIO]
# USER LED
USER_LED = gpio1,23
# USER BUTTON
USER_BUTTON = mca-gpio,1
Aliases for GPIO using Linux IDs
It contains a list of the human-readable names associated with their corresponding GPIO Linux IDs. They must follow the format:
<alias> = <kernel_number>
Where:
-
<alias>
is the human-readable name for the GPIO. -
<kernel_number>
is the GPIO Linux ID.
[GPIO]
# USER LED - I/O Expander IO23
USER_LED = 488
# USER BUTTON - MCA_IO1
USER_BUTTON = 505
PWM section
This is an optional section to identify PWMs. It contains a list of the human-readable names associated with their corresponding PWM identifiers. They must follow the format:
<alias> = <pwm_chip>,<pwm_channel>
Where:
-
<alias>
is the human-readable name for the PWM. -
<pwm_chip>
is the PWM chip. -
<pwm_channel>
is the PWM channel used by that PWM chip.
[PWM]
# PWM1 on Expansion connector (pin 27).
DEFAULT_PWM = 0,0
I2C section
This is an optional section to identify I2C buses. It contains a list of the readable names associated with their corresponding I2C bus number. They must follow the format:
<alias> = <i2c_bus>
Where:
-
<alias>
is the human-readable name for the I2C. -
<i2c_bus>
is the I2C bus.
[I2C]
# I2C-1 on I2C board connector.
DEFAULT_I2C_BUS = 0
SPI section
This is an optional section to identify SPI buses. It contains a list of the human-readable names associated with their corresponding SPI number and slave. They must follow the format:
<alias> = <spi_device>,<spi_slave>
Where:
-
<alias>
is the human-readable name for the SPI. -
<spi_device>
is the SPI device number. -
<spi_slave>
is the SPI slave index to communicate with (SS).
[SPI]
# SPI-1 on SPI board connector, slave 0.
DEFAULT_SPI = 0,0
ADC section
This is an optional section to identify ADC buses. It contains a list of the human-readable names associated with their corresponding ADC identifiers. They must follow the format:
<alias> = <adc_chip>,<adc_channel>
Where:
-
<alias>
is the human-readable name for the ADC. -
<adc_chip>
is the ADC chip. -
<adc_channel>
is the ADC channel used by that ADC chip.
[ADC]
# ADC1_IN2 on GPIO board connector (pin 13)
DEFAULT_ADC = 0,2