Set GPIO right after boot up

  • Hi there,

    we have a two color indicator LED connected to two GPIOs. The LED shows different states of the system. As the LEDs are controlled by the M7 so it takes some time till the user can see that the system is running.
    What we need, is that both GPIOs(GPIO4_IO20,GPIO3_IO22) are set to high not long after powering the system on. A time of about 500-1000ms would be sufficient so we thought of modifying u-boot.


    Questions:

    1. Is the uboot that is build with the yocto build that one that is already installed on the board?

    2. What would be the easiest way to modify it?

    3. Is there an example, and are the GPIO names the same as in linux?

    4. Do you suggest another solution?


    Thanks!

  • Hello,


    1. Is the uboot that is build with the yocto build that one that is already installed on the board?

    By default, yes but if you have a special customer variant it may differ.


    2. What would be the easiest way to modify it?

    The easiest way would be the Uboot gpio command, because you would not have to recompile U-Boot:

    Code
    1. Usage:
    2. gpio <input|set|clear|toggle> <pin>
    3. - input/set/clear/toggle the specified pin
    4. gpio status [-a] [<bank> | <pin>] - show [all/claimed] GPIOs

    You could add them to the bootcmd environment variable before booting into linux. But you will have to test if this is quick enough.


    3. Is there an example, and are the GPIO names the same as in linux?

    You should be able to use GPIO reference card https://www.fs-net.de/assets/d…PIO-ReferenceCard_eng.pdf

    or the same formula as in Linux so the GPIO number for GPIO4_IO20 is (( 4-1)*32)+20)=116.

    However, if the default pad mux of the pin, which you are using is not GPIO it might not work.


    4. Do you suggest another solution?

    A faster way would be, to set the GPIOs during uboot start in the board file for example at

    https://github.com/FSEmbedded/…fsimx8mp/fsimx8mp.c#L1044


    You could take the following code as example

    https://github.com/FSEmbedded/…/fsimx8mp/fsimx8mp.c#L797

    https://github.com/FSEmbedded/…/fsimx8mp/fsimx8mp.c#L767


    However, of the GPOIs are normally set by the MCore, sharing them between cores should be avoided.

    When is your MCore application started? In Uboot or Linux?


    If it is Linux you might consider writing a small MCore program to set the GPIOs and run in in Uboot using the bootaux command.



    Your F&S Support Team