# Kernel Module Load Order

**URL:** <https://mangoh.discourse.group/t/kernel-module-load-order/2673>\
**Category:** Build your own\
**Created:** [May 30, 2019, 5:15pm UTC](https://mangoh.discourse.group/t/kernel-module-load-order/2673 "2019-05-30T17:15:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 30, 2019, 5:15pm UTC](https://mangoh.discourse.group/t/kernel-module-load-order/2673/1 "2019-05-30T17:15:20Z")

</div>

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](https://mangoh.discourse.group/t/the-mangoh-repository-now-uses-a-legato-18-05-1-feature/1610)

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.

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [May 30, 2019, 6:16pm UTC](https://mangoh.discourse.group/t/kernel-module-load-order/2673/2 "2019-05-30T18:16:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 30, 2019, 8:15pm UTC](https://mangoh.discourse.group/t/kernel-module-load-order/2673/3 "2019-05-30T20:15:22Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [May 30, 2019, 8:31pm UTC](https://mangoh.discourse.group/t/kernel-module-load-order/2673/4 "2019-05-30T20:31:30Z")

</div>

[https://elinux.org/Debugging\_by\_printing#Log\_Levels](https://elinux.org/Debugging_by_printing#Log_Levels)

---

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 30, 2019, 9:44pm UTC](https://mangoh.discourse.group/t/kernel-module-load-order/2673/5 "2019-05-30T21:44:09Z")

</div>

@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](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.

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [May 30, 2019, 9:46pm UTC](https://mangoh.discourse.group/t/kernel-module-load-order/2673/6 "2019-05-30T21:46:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dbeckwith](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dbeckwith/32/2139_2.png) [@dbeckwith](https://mangoh.discourse.group/u/dbeckwith)\
**Post date:** [May 30, 2019, 9:52pm UTC](https://mangoh.discourse.group/t/kernel-module-load-order/2673/7 "2019-05-30T21:52:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Zahid](https://avatars.discourse-cdn.com/v4/letter/z/e79b87/32.png) [@Zahid](https://mangoh.discourse.group/u/Zahid)\
**Post date:** [June 3, 2019, 3:21pm UTC](https://mangoh.discourse.group/t/kernel-module-load-order/2673/8 "2019-06-03T15:21:31Z")

</div>

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](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](http://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.
