Code Monkey home page Code Monkey logo

gpio-boot-reset's Introduction

GPIO boot reset

This project is using linux kernel legacy gpio to control reset and boot mode of any mcu.Tested on linux kernel version 3.10.49 For newer version, checkout branch 3.18

Setup

Device tree

In order to run this module, device tree must have node name gpio-boot-reset The driver will parse flowing propreties of gpio-boot-reset's child node

  • reset: propreties that point to the that connect to reset pin of mcu (mandatory)
  • boot: propreties that point to gpio that connect to boot pin of mcu (mandatory)
  • reset-time: time of each reset pluse, default: 25 (unit: us) (optional)
  • boot-time: time to hold boot pin after reset complete, default: 10 (unit: us) (optional)
  • reset-active-low: boolean, determine reset gpio pin is active low (optional)
  • boot-active-low: boolean, determine boot gpio pin is active low (optional)

Example:

gpio-boot-reset{
    compatible = "gpio-boot-reset";
    status = "okay";

    pinctrl-0 = <&reset_pin_off>;
    stm32f042c4{
            reset = <&msm_gpio 95 0>;
            boot = <&msm_gpio 17 0>;
            reset-time = <20>;
            boot-time = <10>;
    };

    nfc {
            reset = <&msm_gpio 16 0>;
            boot = <&msm_gpio 93 0>;
            reset-time = <20>;
            boot-time = <3000>;
    };
};

example's external pinctrl-0

reset_pin { 
    qcom,pins = <&gp 95>, <&gp 17>, <&gp 16>, <&gp 93> ;

    qcom,num-grp-pins = <4>;
    label = "reset-gpio-pins";
    reset_pin_off: stm32f042c4_gpio_off {
        drive-strength = <2>;
        bias-disable; /* no pullup */
        output-low;
    };
};

Reset partern

This module only support 1 reset and boot partern only:

  • Reset: reset high -> wait for reset-time -> reset low
  • Boot: boot high -> reset high -> wair for reset-time > reset low -> wait for boot-time -> boot low

Build

Provide your target kernel using KERNEL_SRC (default is host kernel directory /lib/modules/$(shell uname -r )/build) variable using following code

make KERNEL_SRC=/PATH/TO/YOUR/KERNEL/SOURCE

To clean unnecessary file

make clean

Running

After install module into kernel, there will be 1 file attribute for each child node /sys/class/gpio_boot_reset/*/mode To reset MCU use

echo -n "normal" > /sys/class/gpio_boot_reset/{child_node_name}/mode

To enter bootloader mode

echo -n "prog" > /sys/class/gpio_boot_reset/{child_node_name}/mode

With example device tree above, we will have 2 folder, which coresponse to 2 child node in device tree: /sys/class/gpio_boot_reset/stm32f042c4/mode and /sys/class/gpio_boot_reset/nfc/mode

License

This project is licensed under the GPLv2 License - see the LICENSE file for details

gpio-boot-reset's People

Contributors

thomasthongce avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.