Kernel Module Load Order

I’m cleaning up our kernel modules by adding the required kernel modules to my MDEF files the same as Mangoh The mangOH repository now uses a Legato 18.05.1 feature

I changed the order my kernel modules load (specifically the BMI160 and IIO) to match the Mango Red .mdef file and then they won’t load. I change the order back and then it works.

Old way that works in SDEF
// BMI160 accelerometer, NOTE: Order id important here
$PROJ_ROOT/drivers/bmi160/bmi160
$PROJ_ROOT/drivers/bmi160/bmi160-i2c

// battery charger
$PROJ_ROOT/drivers/bq24296/bq24296

// Required for BMI160 NOTE: Order is important here
$PROJ_ROOT/drivers/iio/iio
$PROJ_ROOT/drivers/iio/iio-kfifo-buf
$PROJ_ROOT/drivers/iio/iio-triggered-buffer

Mangoh Red way that doesn’t work in SDEF
// BMI160 accelerometer, NOTE: Order id important here
$PROJ_ROOT/drivers/bmi160/bmi160-i2c
$PROJ_ROOT/drivers/bmi160/bmi160

// battery charger
$BRNKL_ROOT/drivers/bq24296/bq24296

// Required for BMI160 NOTE: Order is important here
$BRNKL_ROOT/drivers/iio/iio-triggered-buffer
$BRNKL_ROOT/drivers/iio/iio-kfifo-buf
$BRNKL_ROOT/drivers/iio/iio

Thoughts? Is there something I’m missing with the new method. I’m running Legato 18.09.0 on a WP85.

Take a look at dmesg and logread output and see if there are any clues in there about why the modules are failing to load.

@dfrey I’m not seeing a lot of my print states in dmesg or the log. How do I enabled the DEBUG level messages in the kernel modules?

https://elinux.org/Debugging_by_printing#Log_Levels

@dfrey Thanks I looked at that resource and it wasn’t much help. I have several of these dev_dbg statements but I don’t seem them in the dmesg or logread

I am basically recreating what you did here https://github.com/mangOH/mangOH/commit/fd1399c48c7924930bace8334071c589ec3c26ec moving from the number files to the requires statements but it’s not working.

Any additional help would be greatly appreciated, thanks.

The quick and dirty method is to raise the log level of the messages so that they do appear. I too have had issues with “debug” level messages and never really got to the bottom of it.

So what’s the difference between dev_info and printk? Any thoughts on my comments about moving away from the number based kernel module loading to the requires statements?

Hi, dev macros call into printk with the different levels as @dfrey mentioned.
They are the recommended way of printing log messages in device drivers
these days, just like pr_ are in many kernel subsystems. I think you may not be
seeing messages as if you look at your Kernel config it probably has this set:
CONFIG_DYNAMIC_DEBUG=y
This means you have to turn on you device debug messages on the target at
run-time on the fly as explained here:
https://www.kernel.org/doc/html/v5.1/admin-guide/dynamic-debug-howto.html
There are also other reasons dev_dbg doesn’t print. Please see the kernel.org
docs for more details.

I’m unsure about the Legato module loading ordering issues, I’ll let @dfrey
pipe in on those once you get the log messages.