[yocto] Power off IC over Yocto

Michael Habibi mikehabibi at gmail.com
Thu Dec 17 21:37:28 PST 2015


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.

On Wed, Dec 16, 2015 at 6:37 AM, simo <sazzalin at settopsurvey.com> wrote:

> 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
>
>
> El mar, 15-12-2015 a las 19:46 +0100, Christian Ege escribió:
> >
> > Am 15.12.2015 7:45 nachm. schrieb "Christian Ege" <k4230r6 at gmail.com>:
> > >
> > > Hi,
> > >
> > > Am 15.12.2015 6:45 nachm. schrieb "simo"
> > <sazzalin at settopsurvey.com>:
> > > >
> > > > 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?
> > > I guess you can use
> > > http://lxr.free-electrons.com/source/kernel/reboot.c
> > >
> > register_reboot_notifier is your friend
> > > You have to create some kernel module doing this or write a kernel
> > patch.
> > >
> > > Regards,
> > > Christian
> > >
> > > > --
> > > > _______________________________________________
> > > > yocto mailing list
> > > > yocto at yoctoproject.org
> > > > https://lists.yoctoproject.org/listinfo/yocto
> >
> >
>
>
> --
> _______________________________________________
> yocto mailing list
> yocto at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20151217/9e3ab6c6/attachment.html>


More information about the yocto mailing list