Power off IC over Yocto
I am using a Gumtix Overo board and we create and expansion board that power Overo and other devices by external power supply IC.
Our expansion board with power supply are connected by I2C bus 2 in overo (not the same i2C that TW4030 or tps6595 is connected).
Using the Linux command shutdown we would like to power off the hole system.
We would like to close the linux and last thing send a command over I2C to our power supply IC in order it disconnect the physical power.
Our question is:
Where we have to implement that function?
Is there any example of it?
Hi,
Am 15.12.2015 6:45 nachm. schrieb "simo" <[email protected]>:
Quoted 12 lines
I am using a Gumtix Overo board and we create and expansion board that power Overo and other devices by external power supply IC.
Our expansion board with power supply are connected by I2C bus 2 in overo (not the same i2C that TW4030 or tps6595 is connected).
Using the Linux command shutdown we would like to power off the hole system.
We would like to close the linux and last thing send a command over I2C to our power supply IC in order it disconnect the physical power.
Quoted 4 lines
Our question is:
Where we have to implement that function?
Is there any example of it?
I guess you can use
http://lxr.free-electrons.com/source/kernel/reboot.c
You have to create some kernel module doing this or write a kernel patch.
Regards,
Christian
Quoted 5 lines
--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto
Am 15.12.2015 7:45 nachm. schrieb "Christian Ege" <[email protected]>:
Quoted 16 lines
Hi,
Am 15.12.2015 6:45 nachm. schrieb "simo" <[email protected]>:
Quoted 12 lines
I am using a Gumtix Overo board and we create and expansion board that power Overo and other devices by external power supply IC.
Our expansion board with power supply are connected by I2C bus 2 in overo (not the same i2C that TW4030 or tps6595 is connected).
Using the Linux command shutdown we would like to power off the hole system.
We would like to close the linux and last thing send a command over I2C to our power supply IC in order it disconnect the physical power.
Quoted 7 lines
Quoted 4 lines
Our question is:
Where we have to implement that function?
Is there any example of it?I guess you can use
http://lxr.free-electrons.com/source/kernel/reboot.c
register_reboot_notifier is your friend
Quoted 10 lines
You have to create some kernel module doing this or write a kernel patch.
Regards,
ChristianQuoted 5 lines
--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto
Hi,
right now we solved executing an external tool we wrote in C to send the I2C command to the external expansion board.
I had to modify the kernel_halt() function as follows:
void kernel_halt(void)
{
/* added by simo */
/* external environment declaration */
char i2c_shutdown_cmd[] = "/home/root/i2c-shutdown";
char **argv;
static char *envp[] =
{
"HOME=/",
"PATH=/home/root:/sbin:/usr/sbin:/bin:/usr/bin",
NULL
};
argv = argv_split(GFP_KERNEL, i2c_shutdown_cmd, NULL);
// WORKS HERE
pr_emerg("Turning off.\n");
call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
/* no more executed */
kernel_shutdown_prepare(SYSTEM_HALT);
migrate_to_reboot_cpu();
syscore_shutdown();
//pr_emerg("System halted\n");
kmsg_dump(KMSG_DUMP_HALT);
/* commented while(1); in machine_halt for arm */
machine_halt();
}EXPORT_SYMBOL_GPL(kernel_halt);
I cannot execute call_usermodehelper after kernel_shutdown_prepare() because this function disables user space access.
So I have a question: how much is important to execute the code until machine_halt() ?
I am using a kernel version 3.18.18.
Regards,
Simon
Quoted 44 lines · Christian Ege
Am 15.12.2015 7:45 nachm. schrieb "Christian Ege" <[email protected]>:
Quoted 4 lines
Hi,
Am 15.12.2015 6:45 nachm. schrieb "simo"
Quoted 2 lines
Quoted 2 lines
I am using a Gumtix Overo board and we create and expansion board
that
Quoted 3 lines
Quoted 3 lines
power Overo and other devices by external power supply IC.
Our expansion board with power supply are connected by I2C bus 2
in
Quoted 3 lines
Quoted 3 lines
overo (not the same i2C that TW4030 or tps6595 is connected).
Using the Linux command shutdown we would like to power off the
hole
Quoted 2 lines
Quoted 2 lines
system.
We would like to close the linux and last thing send a commandover I2C
Quoted 9 lines
Quoted 6 lines
to our power supply IC in order it disconnect the physical power.
Our question is:
Where we have to implement that function?
Is there any example of it?I guess you can use
http://lxr.free-electrons.com/source/kernel/reboot.c
register_reboot_notifieris your friendQuoted 1 line
You have to create some kernel module doing this or write a kernel
patch.
Quoted 9 lines
Regards,
ChristianQuoted 5 lines
--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto
Simon, that's more of a kernel development question and probably doesn't fit in the Yocto project mailing list. You may try the linux kernel development mailing lists.
However, I will give you some feedback. I think you are modifying code too deep in the kernel. By the time you get to that function, the system should not be executing more tasks. If it does, it will likely get terminated pretty quickly afterward, regardless if it finished (no guarantee your process will run to completion). It's also not great practice to actually modify the kernel itself, because then it will only work with your one machine/setup (unless that is acceptable). Kernel modules loaded in may be better practice here.
I don't understand your question about machine_halt, but I will assume you are asking how important the lines of code are between your usermode helper call and machine_halt. The answer is very. All of those lines must execute successfully to have clean shutdown.
Quoted 106 lines · simo
Hi,
right now we solved executing an external tool we wrote in C to send the I2C command to the external expansion board.
I had to modify the
kernel_halt()function as follows:void
kernel_halt(void)
{/* added by simo */ /* external environment declaration */ char i2c_shutdown_cmd[] = "/home/root/i2c-shutdown"; char **argv; static char *envp[] = { "HOME=/", "PATH=/home/root:/sbin:/usr/sbin:/bin:/usr/bin", NULL }; argv = argv_split(GFP_KERNEL, i2c_shutdown_cmd, NULL); // WORKS HERE pr_emerg("Turning off.\n"); call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC); /* no more executed */ kernel_shutdown_prepare(SYSTEM_HALT); migrate_to_reboot_cpu(); syscore_shutdown(); //pr_emerg("System halted\n"); kmsg_dump(KMSG_DUMP_HALT); /* commented while(1); in machine_halt for arm */ machine_halt(); }
EXPORT_SYMBOL_GPL(kernel_halt);I cannot execute
call_usermodehelperafterkernel_shutdown_prepare()because this function disables user space access.So I have a question: how much is important to execute the code until
machine_halt()?I am using a kernel version 3.18.18.
Regards,
SimonQuoted 25 lines · Christian Ege
Am 15.12.2015 7:45 nachm. schrieb "Christian Ege" <[email protected]>:
Quoted 4 lines
Hi,
Am 15.12.2015 6:45 nachm. schrieb "simo"
Quoted 2 lines
Quoted 2 lines
I am using a Gumtix Overo board and we create and expansion board
that
Quoted 3 lines
Quoted 3 lines
power Overo and other devices by external power supply IC.
Our expansion board with power supply are connected by I2C bus 2
in
Quoted 3 lines
Quoted 3 lines
overo (not the same i2C that TW4030 or tps6595 is connected).
Using the Linux command shutdown we would like to power off the
hole
Quoted 2 lines
Quoted 2 lines
system.
We would like to close the linux and last thing send a commandover I2C
Quoted 4 lines
Quoted 4 lines
to our power supply IC in order it disconnect the physical power.
Our question is:
Quoted 19 lines
Quoted 5 lines
Quoted 2 lines
Where we have to implement that function?
Is there any example of it?I guess you can use
http://lxr.free-electrons.com/source/kernel/reboot.c
register_reboot_notifieris your friendQuoted 1 line
You have to create some kernel module doing this or write a kernel
patch.
Quoted 9 lines
Regards,
ChristianQuoted 5 lines
--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto
Hi Michael,
First of all thank for your feedback.
I also don't like to modify the kernel this way, also because it's not portable.
I will look forward to develope a kernel module to do that task.
Quoted 1 line
Quoted 1 line
I don't understand your question about
machine_halt, but I will
assume you are asking how important the lines of code are between your usermode helper call and machine_halt. The answer is very. All of those lines must execute successfully to have clean shutdown.
Yes, I was referring to the execution of
kernel_shutdown_prepare(SYSTEM_HALT);
migrate_to_reboot_cpu();syscore_shutdown();kmsg_dump(KMSG_DUMP_HALT);machine_halt();
Because it's supposed that after sending the I2C command (to power off the board) before the execution of these function, they will not be executed.
Thanks again.
Simon
Quoted 13 lines · Michael Habibi
I think you are modifying code too deep in the kernel. By the time you get to that function, the system should not be executing more tasks. If it does, it will likely get terminated pretty quickly afterward, regardless if it finished (no guarantee your process will run to completion). It's also not great practice to actually modify the kernel itself, because then it will only work with your one machine/setup (unless that is acceptable). Kernel modules loaded in may be better practice here.
I don't understand your question about
machine_halt, but I will assume you are asking how important the lines of code are between your usermode helper