[yocto] Power off IC over Yocto

simo sazzalin at settopsurvey.com
Wed Dec 16 04:37:58 PST 2015


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





More information about the yocto mailing list