Switch off linux running only on RAM - linux

I'm working on an Embedded board that has a battery to keep the system alive in case of power fail, if I detect a power fail I just need to flush all and switch off the system.
The problem is that the NAND(/dev/root) is not powered by the battery, so I don't have access to NAND memory, I manage to flush all my data thanks to some capacitors that gives me about 200ms to save and flush all but then I can't switch off the system I guess because Linux tries to access to /dev/root that is not powered up, is there a way to switch off the system without writing anything into /dev/root during the shutting down?
Thanks in advance

Related

How to keep wifi link up when an embedded linux device suspends to RAM

Environment:
I have an embedded linux system running with an ARM based iMX7 processor. It runs on a build from yocto linux which is very much based on Fedora.
Scenario:
My system uses Suspend To RAM feature which is linux system power saving mode that is explained quite well in this link. This is done to save power at a certain stage.
Objective:
Now, I need to keep the wifi link open during this stage. And as I read from some discussions like this, it seems to be possible to do so.
How can I do this?
Read up on similar discussions:
Reading through this discussion, it explains how to do this on a intel based desktop linux computer. But I don't have the /etc/NetworkManager on my embedded linux device. Probably there is a different way to do it on a Fedora based embdded linux system.
Can I get some suggestions on how to do this or even how to approach this?
None of the articles you quoted even suggest that it is possible to leave WiFi on - in fact one of them says it can't be done. All they provide is various tricks to make the wake-up faster.
Depends on the hardware but very likely, leaving it on is really impossible. Suspend-to-ram includes a hardware command that switches the CPU clock off, places its interconnect buses into idle state, and disables main power to all the peripherals (leaving only standby power to those peripherals that support standby mode).
I don't know if your WiFi device has support for running on standby power nor whether the embedded hardware you have has the ability to provide that power to it while the CPU is off. If that ability exists, it will likely be accessible as a kernel driver parameter.
You may be able to save some startup time when waking up from standby by providing a static configuration for your WiFi device rather than using the default automatic connection (which involves searching for a router to connect to, obtaining an IP address, etc.).
You can't just keep wifi active during sleep/resume. You can optimise reconnection speed but I believe NM and connman both do that already.

shared mem betwwen kernel/user space and select

I have some specific hardware which run on FreeBSD and Linux.
I have to do an user space application which will work with the driver using shared memory between kernel/user space application.
My application does busy poll on the shared mem from user space.
Is there any idea how I can use a mechanism such select to sleep and to get notify on shared memory change (buy the driver) ?
I dont want to implement some communication like netlink, because the idea with select is to sleep, to wake up if something happens, and to keep awake and keep processing data without handing more IPC with the kernel.
And then, when it will be done, the application can call again select and wait again.
Thank you.
You are looking for the kqueue(2) interface on FreeBSD.
On Linux there is inotify/epoll.

Ensure all data is flushed from user space to eMMC memory

I am working with embedded Linux system, where software should be replaced in power fail safe manner, and that when we signal that procedure is complete power failure should not negatively affect the system.
Documentation for sync syscall mentions that this flushes only the kernel buffers, and internal device (like eMMC) buffers can still be not fully flushed.
I was looking through /dev/mmc directories, and found the file called "removeable" which should allow to have behavior similar to actually removable devices (where power is disconected on removal in abrupt way).
Does Linux eMMC drivers has sth more dedicated to fully flush eMMC card/prepare it for power loss?

Suspend a device in Linux

I am thinking of suspending a particular platform device driver, while keeping rest of the system active.
Can this selective suspend be achieved by Linux Power Management? Or
Can I write a separate driver that can do this for me, by calling suspend directly on the platform device driver?
For hard disks you can try hdparm command for set hard disk in standby. The option you might be looking for is -S.
According linux man pages:
Put the drive into idle (low-power) mode, and also set the standby (spindown) timeout for the drive. This timeout value is used by the drive to determine how long to wait (with no disk activity) before turning off the spindle motor to save power.

interrupts to notify events in linux

I want to write a program which notifies when the laptop battery level falls below a certain threshold level. I am using ubuntu 11.04 . Is there a way in which i can generate an interrupt without polling the battery. What system calls in linux are used to achieve this ?
There is no system call interface to ACPI in Linux... All of the I/O is done using /proc/acpi or /sys/class entries. Easiest implementation would be a polling software, and read the interface periodically (going to sleep if the threshold is not there yet) — this is because typically /proc and /sys files construct the desired information while handling the read(2).

Resources