HowTo: Register GPIO reset button for OoliteV5.1

OoliteV5.1 base board have one reset button. However this reset button connected to cpu reset.

So if you need a software reset button instead of hardware reset, you need do some works follow this:

 

1. regist GPIOx to kernel core, please modify machine file "mach-oolite-v5.c" follow below:

I) define some macros for GPIOx:

#define OOLITE_V5_GPIO_BTN_RST                             17

#define OOLITE_V5_KEYS_POLL_INTERVAL                  20     /* msecs */

#define OOLITE_V5_KEYS_DEBOUNCE_INTERVAL        (3 * OOLITE_V5_KEYS_POLL_INTERVAL)

II) initialize gpio_keys_button sturcture:

static struct gpio_keys_button oolite_v5_gpio_keys[] __initdata = {
        {   
                .desc           = "reset button",
                .type           = EV_KEY,
                .code           = KEY_RESTART,
                .debounce_interval = OOLITE_V5_KEYS_DEBOUNCE_INTERVAL,
                .gpio           = OOLITE_V5_GPIO_BTN_RST,                                                                                                                                 
                .active_low     = 1,
        },  
};

III) regist keys into kernel core:

 ath79_register_gpio_keys_polled(-1, OOLITE_V5_KEYS_POLL_INTERVAL,
                        ARRAY_SIZE(oolite_v5_gpio_keys),
                        oolite_v5_gpio_keys);

 

2. if you are using OpenWRT/LEDE, you can use reset button of short pressing for reboot and long pressing for factory reset.

    if you are using QSDK source, please complete hotplug event for reset button like below:

I) create a file in "package/base-files/files/etc/hotplug.d/button/" named "01-button-reset":

> touch package/base-files/files/etc/hotplug.d/button/01-button-reset

II) create event for reset button:

[ “$ACTION” = “released” ] || exit 0                                                                                                                                                      

. /lib/functions.sh

logger "$BUTTON pressed for $SEEN seconds"

if [ “$SEEN” -lt 1 -a “$BUTTON” = “reset” ]; then
        echo "REBOOT" > /dev/console
        sync
        reboot
elif [ “$SEEN” -gt 5 -a “$BUTTON” = “reset” ]; then
        echo "FACTORY RESET" > /dev/console
        firstboot -y
        reboot
fi

return 0

 

3. now you can use reset button.

 

Comments

So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar