Page 1 of 1

hardware reset

Posted: 2024-11-16 0:39
by alex9x
Hello!

Need to make hardware reset of board and usb modem on it by switching relay with power.
(By default power goes from NC to COM contact on relay, then simple scheme with optocoupler and npn makes relay switch and board lost power and in a few seconds relay back to powering board.)

This work on MTK, they have hardware reset output that can drive relay circuit or direct power controller ic with enable/reset signal (it was maked to reset external spi flash as I understand, it have pullup and active low state).

Any information about ability to add Luckfox boards this function.
Need correct closing fs and etc like on reboot command, but with hardware reset signal to other circuit.

Maybe can send some reset reason to bootloader? and make this hardware reset during bootloader? (this also mt7688 experience)

Do not found "shutdown" command, maybe any ideas with it.

Any suggestions are welcome.

Thanks!

Re: hardware reset

Posted: 2024-11-16 2:38
by Crocodile
Hello, use the halt command in the system to shut down the system.
The NPOR pin on the RV1106 is controlled by the reset key and can be used to shut down the system if the RV1106 series is used
There is no NPOR pin on the RV1103 but you can write a program that executes the halt command to achieve similar functionality when it recognizes that a pin is triggered. Note that this method must ensure that the system has entered rootfs, and there is no way to receive it during the uboot phase and kernel boot phase.
Different from the mt7688 experience you described, rv1103/rv1106 If you directly reset spi flash during the kernel boot phase, it may cause kernel crash and will not trigger system restart. It will not achieve the functions you need.

Re: hardware reset

Posted: 2024-11-16 10:21
by alex9x
May be you don`t understand me, I need make some pin high before software kernel reset (it shows "reboot: Restarting system" message before reboot). Or make triggering one pin before this message (seems need look into kernel?). Some hardware duplication of software reset that will reset power line of board and modem. NPOR is reset input, and I need reset output.

Simplest way is gpio-leds, make a led with class leds, connect coupler on this pin and make on trigger when need to reset board, but this will hardware reset without correct fs close and other interface disconnections.

Re: hardware reset

Posted: 2024-11-18 3:53
by Crocodile
According to "Need to make hardware reset of board and usb modem on it by switching relay with power." my understanding is...

Code: Select all

The level state of a pin of luckfox pico is changed by relay--> luckfox detects a level transition and restarts
And your latest explanation, my understanding,

Code: Select all

luckfox pico receives restart signal--> luckfox pico controls a pin level transition--> luckfox pico restart
I'm sorry, but I still don't understand what your needs are. Can you elaborate on the process you expect?

Re: hardware reset

Posted: 2024-11-20 18:01
by alex9x
In a few words - need make daily hardware reset by disabling board power by external relay, for example each day in 2:00 AM.
By now I use script from cron for hardware reset:

Code: Select all

#!/bin/sh
sync
sleep 2
echo default-on >/sys/class/leds/hw_reser/trigger
Led device named hw_reset connets PC817 with relay, that normal connected and powered board.
Relay have a capacitor and it disable power about 2 seconds, than back powering board. This enough to reset modem and board.

Does it enough "sync" command to properly close FS? What other need to make?

board.jpg

Any ideas are welcome.
Thanks!

Re: hardware reset

Posted: 2024-11-21 1:58
by Crocodile
Currently, my approach is to use a GPIO pin, let’s say GPIO1_D1, which is initially set to low level. The relay is connected using the normally closed (NC) wiring to GPIO1_D1.

1 When GPIO1_D1 outputs a high level, the relay disconnects the power supply. However, due to the presence of a capacitor, the power supply can still be maintained temporarily.
2 GPIO1_D1 continues to output a high level until the capacitor's power is depleted, causing a hardware-level power cut. At this point, the relay, using the normally closed connection, restores the power supply.
3 After the Luckfox Pico restores power, it reboots and enters the system again.

Your concern seems to be about the risk of improper power-off and restart potentially compromising the stability of the file system. While we haven’t conducted industrial-grade testing, and in daily use, the impact of direct power-off is minimal, it still cannot be ignored. Therefore, my solution is to delay the GPIO1_D1 high-level output to the final stage of the restart process.

On the RV1106, the shutdown or reboot process will invoke the /etc/init.d/rcK script to close related hardware or background services. The system executes /etc/init.d/S* stop scripts in sequence by numerical order. Hence, a custom script can be created as /etc/init.d/S99custom.

Code: Select all

#!/bin/sh
[ -f /etc/profile.d/RkEnv.sh ] && source /etc/profile.d/RkEnv.sh

gpio_output_h() {
	sleep 2 #Wait for scripts in the same run order to finish running
	echo 57 > /sys/class/gpio/export
	echo out > /sys/class/gpio/gpio57/direction
	echo 1 > /sys/class/gpio/gpio57/value
}


case $1 in
	stop)
		gpio_output_h & # Running in the background to prevent blocking
		;;
	*)
		exit 1
		;;
esac

Re: hardware reset

Posted: 2024-12-05 11:05
by alex9x
Hello!
Are you sure that before running last init.d script system will correctly close fs? Seems my answer is NO.
FS is only one that need to be correctly closed before reboot or shutdown. This is last step before sending hardware reset signal from os/kernel in unix.

Please, advise about read-only file systems. If I will mount them in mtab as ro - no any fail for device?
We talk about ready device, not development. Not using camera or other RK things, only clean unix system, only one C program runs as daemon on startup, it serve all that need, without any logs on device.
Like internet router for example, they have basically RO root system with RW overlay for config files.

Thanks!