Using fixed device table instead of udev - embedded-linux

I'd like to generate a fixed device table in my embedded Linux image and skip using udev.
Following the Yocto Dev Manual, chapter* 5.18.1*, I've set the 2 variables USE_DEVFS="0" and IMAGE_DEVICE_TABLES = "device_table-mymachine.txt" and removed udev from the variable VIRTUAL-RUNTIME_dev_manager.
But the table was not created and I still need udev to populate devices.
Does anyone have an idea?

I am not sure how you have defined device_table-mymachine.txt but this is device_table-minimal.txt for example.
Secondly, without udev, you need to add another device manager such as BusyBox's mdev by specifying it in your conf/local.conf file as follow:
VIRTUAL_RUNTIME_dev_manager = "mdev"
Note that this will work only with core images that include packagegroup-core-boot

Related

Adding wifi SSID and PASSWORD to sdkconfig

I'm creating a wifi application using ESP-IDF based on the examples but the example I'm using has options for setting the SSID and PASSWORD under:
Example Connection Configuration
when using idf.py menuconfig and which are used by CONFIG_EXAMPLE_WIFI_SSID and CONFIG_EXAMPLE_WIFI_PASSWORD in the code.
I want to set SSID and PASSWORD in my own project without using this in CMakeLists.txt:
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
without the above there isn't a way to define SSID and PASSWORD. They appear in:
build/config/kconfig_menus.json
but I can't seem to keep this from being overwritten in my own project. sdkconfig states it should not be edited.
Is there a best practice for using idf.py menuconfig? Or do most people just use sdkconfig.defaults and not use idf.py menuconfig?
I eventually tracked down the file Kconfig.projbuild in the example project via the build system docs:
Each component may also include a Kconfig file defining the component
configuration options that can be set via menuconfig. Some components
may also include Kconfig.projbuild and project_include.cmake files,
which are special files for overriding parts of the project.
created my own version and put it in main and the options now appear when using idf.py menuconfig. Thanks to this video.
When we use ESP-IDF example and change config using idf.py menuconfig there is one config option example configuration that is custom or user's own configuration created by espressif. And we can also make our own configuration like that.
Kconfig.projbuild is used for making our own configuration. for details see below links.
how-to-add-custom-configuration-in-project-config
Espressif official doc

SELinux init_daemon_domain(avahi_t,avahi_exec_t) vs. files_types(avahi_t)

I am running into a problem with labeling. In order to lock down access to a file /etc/avahi/avahi-daemon.conf I decided to label it as a part of the avahi_t domain.
I am working on an embedded system. When I boot up the system from a version update, the file system is relabeled with the .autorelabel flag set.
Unfortunately the file /etc/avahi/avahi-daemon.conf remains in the unlabeled_t type. Due to the label being wrong, it is unable to read the file and avahi fails to initialize properly with an avc read denied on an unlabeled_t file. I want to have the label correctly set and not modify policy to read an unlabeled file. I also want it to be protected so the configuration can not be modified.
I have properly labeled it in the .fc file with the following:
/etc/avahi/avahi-daemon.conf -- gen_context(system_u:object_r:avahi_t,s0)
When I try a restorecon on the file system it attempts to relabel the file but is blocked by SELinux with a relabelto avc violation. Similarly changing it with chcon -t fails to change it. I do not wish to open relabelto up on an embedded system as it can then be relabeled and take down the avahi initialization. If I take out the SD card, and relabel the file on a different system. And place it back into the target system it is properly labeled. And avahi operates correctly. So I am certain that the labeling is causing the problem.
In looking in the reference policy an init_daemon_domain(avahi_t,avahi_exec_t) is being performed.
In looking at the documentation for init_daemon_domain() it states the following:
"The types will be made usable as a domain and file, making calls to domain_type() and files_type() redundant."
This is unusual in that if I add files_type(avahi_t) to the .te file, it properly labels after version update.
I am really wanting to know more information about this, and unfortunately my searches on the internet have been less than fruitful in this regard.
Is the documentation for SELinux wrong? Am I missing something about init_daemon_domain() in that it only works with processes and not files?
Or is the files_type(avahi_t) truly needed?
I know this comes off as a trivial issue since there is a path to where it is working. However I am hoping to get an explanation as to why files_type(avahi_t) is necessary?
Thanks

How can I add a user to login as a user and not as a root Yocto project sama5d27 board

I am using sama5d27 som1 ek1 board and I build a Linux kernel for it using yocto project. I open minicom and the system boot. I want to remove debug tweaks from my image features but I must now set a user to my board to login and stop login as a root. How can I add a user to my board ?
You have to use one of the useradd classes. The documentation is there:
https://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html#ref-classes-useradd
The meta-skeleton/recipes-skeleton/useradd/useradd-example.bb recipe show you how to do that dynamically.
You can also provide the uids and gids statically by using USERADDEXTENSION = "useradd-staticids" in local.conf or, preferably in your distro and then having files/passwd and files/group anywhere in your BBPATH.

Permanently blacklist linux kernel module

I have pcspkr in blacklisted in /etc/modprobe.d/pcspkr.conf. However, I can manually load the module using modprobe.
I'm guessing, some other component will be able to do the same via module alias mechanism. Is there a way to permanently block automatic loading of a specific kernel module?
My use case is that I want to experiment with an alternative driver than the one provided in-tree. For this, I do not want the system's default driver showing up. I do not want to delete the golden driver provided by the kernel and screw up either.
What options do I have ?

How to configure spi in the driver file insted of giving configuration in the application

I want to write a test driver for mcspi and want to give all configuration in my driver file (instead of using user space application I want to use driver as a test driver and want to create .ko) and want to pass all configuration to the mcspi controller.
The configurations like chip_select, mode, speed, bits etc., Basically all these configurations I want to use for my test driver to check functionality of FIFO mode in the mcspi. I have already enabled FIFO in the mcspi but I want to check its functionality.
Can anyone please give me some suggestions?
I don't really know why cant you do something you want. I think you can pass the configuration by set up parameters using module_param
Adding on what #sunnyleevip suggested: another "standard" way to configure your driver would be to expose the params of interest via the /proc or the /sys filesystems.
You can find all the details in Linux Device Driver
Expanding on #sergico and #sunnyleevip, you could also use device tree to pass configuration data to the driver. The SPI bus master driver (since the 2.6.30s and all of the 3.x kernels) already are pretty devicetree supportive, so there might not be much more to do to get it to work.

Resources