I am using Anmdroid 14.0.0_1.2.0 on an i.MX 8MM custom hardware.
On the hardware there are some peripheral chips where the kernel driver needs to load a firmware from eMMC when the driver module gets loaded.
The related kernel modules are all placed in vendor_dklm partition (passed to the BOARD_VENDOR_KERNEL_MODULES makefile variable) so that they get loaded by the init.rc script when vendor partition is already mounted.
Because of programming firmwares some of these driver take a long to time to load. But system already start while the modules are still in loading process. This might lead to conditions where HAL services get loaded but the related hardware is not ready on driver level yet.
The problem is how the modules get loaded from init.rc script. The loading process is declared as a service. The init.rc file is located in device directory (e.g. device/nxp/imx8m/evk_8mm\init.rc)
service early_init_sh /vendor/bin/init.insmod.sh /vendor/etc/early.init.cfg vendor.all.early_init.ready
class main
user root
group root system
disabled
oneshot
This service is started in early_init phase (see same init.rc file):
on early-init
start early_init_sh
# Set the host name which used in console
export HOSTNAME evk_8mm
When the service as started via the "start" command it is started in the background and init goes on without waiting. So the HAL services are already loaded while the load kernel modules script is still busy in loading the modules.
I would like to propose to start the kernel module loading script with the "exec_start" command. This will make init process wait until the module load service (or the script) terminates and all modules are loaded before going on loading HAL services.
So this is the patch to apply to all related init.rc files which use the same scheme for laoding the kernel modules:
diff --git a/imx8m/evk_8mm/init.rc b/imx8m/evk_8mm/init.rc
index d1d2c1a5..06edc59d 100644
--- a/imx8m/evk_8mm/init.rc
+++ b/imx8m/evk_8mm/init.rc
@@ -7,7 +7,7 @@ on early-init
mount debugfs none /sys/kernel/debug/ mode=0755
on early-init
- start early_init_sh
+ exec_start early_init_sh
# Set the host name which used in console
export HOSTNAME evk_8mm