Sleep and Wake-up Operation of the Embedded T113-i Development Board of Forlinx
System sleep and wake-up technology is the key technology in power management. It allows the system to minimize power consumption when idle, putting external devices, the chip's internal IP, and the clock into a low-power state or a completely power-off state to greatly extend battery life. Additionally, when needed by the user, the system can quickly restore the power, clock, working state of the internal IP of the chip, and external devices, ensuring that the user’s experience is not disrupted.
The embedded OK113i-S development board supports two sleep modes: freeze and mem. These two methods can be operated through the/sys/power/state file node, and the user can trigger the corresponding sleep state by writing freeze or mem to the file node.
Before hibernation, the system configures the wake up source. Once the system enters the sleep state, it can be awakened by these wake-up sources, such as keys, RTC, etc., when needed. This design allows users to choose when and how to wake up the system quickly according to their needs, achieving a balance between power consumption minimization and fast recovery. This mechanism enables the system to greatly reduce power consumption in the sleep state, while retaining the convenience of the user to use the system quickly after waking up.
This article will introduce how to put the embedded OK113i-S development board into sleep mode, and how to achieve timed wake-up through the RTC clock.
01 Two Sleep Modes
Freezing I/O devices, placing them in a low-power state, allows the processor to enter an idle state, resulting in the fastest wake-up time but higher power consumption compared to other methods. Based on the test results with the OK113i-S development board powered only through the serial port, it was found that the current is approximately 0.112A at 5V.
Suspend to the memory. The computer stores the current running state and other data in the memory, closes the hard disk, peripherals and other devices, and enters the waiting state. At this time, the memory still needs power to maintain its data, but the whole machine consumes very little power. When the computer resumes from a suspended state, it reads the data stored in memory and restores itself to the exact state it was in before it was suspended.
This allows for a faster recovery time compared to a full system startup. The measured OK113i-S development board is powered by 5V when only the serial port line is connected, and the current is about 0.076 A.
1. cat /sys/power/state to see what modes are supported by the OK113i-S development board:
2. echo freeze > /sys/power/state Enter freeze mode:
3. echo mem > /sys/power/state Enter mem mode:
02 Timed wake-up via RTC
Note: Internal RTC is required here. The external RTC does not support wake-up function. We will mention this later.
Enter the kernel configuration of the development board:
root@ubuntu: /home/forlinx/work/linux/OK113i-linux-sdk# ./build.sh menuconfig
Select the function according to the box in the following figure:
After the configuration is completed, save it, and then modify the device tree file to open the internal RTC function.
Compile after saving:
After the compilation is successful, it is packaged into an image. After the programming is completed, we test it at the serial port terminal.
Enter the serial port terminal for test:
echo “+15”> /sys/class/rtc/rtc0/wakealarm
You can use this 15-second timer by setting the desired time. Once the timer is set, it will begin counting down and the Real-Time Clock (RTC) will keep track of the time. If the device goes into hibernation mode within the 15-second timer window, it will not trigger the wake-up (Note that the internal RTC is required here, and the external RTC does not support wake-up)
echo mem > /sys/power/state
(The input of the two instructions here should be compact. If the interval between the two instructions is too long, it will be invalid.)
(It should be noted here that when the internal RTC is not opened, the default external RTC node is rtc0. After modification, the external RTC device node will be changed to rtc1.)
Here, we have completed all the operations to implement sleep and timed wake-up using the Forlinx Embedded OK113i-S development board. The specific operations may vary on different control platform boards, but the overall approach remains the same. You can refer to relevant documentation for specific steps based on the corresponding platform. We hope the methods provided in this article will be helpful for engineers in their project development.