U-Boot Parameter Set by GPIO

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

U-Boot Parameter Set by GPIO

Jump to solution
3,021 Views
PaulDeMetrotion
Senior Contributor I

I am attempting to use a jumpered GPIO input to control the bootargs of my u-boot variables. I have added the following lines to my u-boot variables. The selected GPIO is read and the bootargs are changed if the bit is set; otherwise, there is no change.

        "bootargs=console=ttymxc2,115200n8 "                    \

            "root=/dev/mmcblk0p2 rootwait rw ${ip_config} "     \

            "lvds_panel=0\0"                                    \

        "setexpr tmpvar *20ac000 '&' 00000100\0"                \

        "if test ${tmpvar} != 0; then setenv bootargs "         \

            "'console=ttymxc2,115200n8 root=/dev/mmcblk0p2 "    \

            "rootwait rw ${ip_config} lvds_panel=1'; fi\0"          \

After booting to the u-boot prompt, the setexpr command does not appear to have executed and as a result the bootargs are never changed. There is no tmpvar in the list of environment variables when I run printenv.

If I execute the setexpr command from the prompt, it appears to work and there is a tmpvar entry in the variables. I can then successfully run the 'if test ...' statement successfully.

Does anybody have experience trying to use GPIO signals during boot? Is the setexpr command only for command prompt use? Am I doing this correctly?

0 Kudos
1 Solution
1,680 Views
PaulDeMetrotion
Senior Contributor I

I fixed this issue! Instead of having the setexpr and if statements as seperate lines, I added them to the bootcmd_mmc line. This resulted in the desired effect of appending the bootargs line based on the GPIO setting.

        "bootargs=console=ttymxc2,115200n8 "                    \

            "root=/dev/mmcblk2p2 rootwait rw ${ip_config}\0"    \

        "bootcmd_mmc= "                                         \

            "setexpr tmpvar *20ac000 '&' 00000100; "            \

            "if test ${tmpvar} != 0; then "                     \

                "setenv bootargs $bootargs lvds_panel=1; else " \

                "setenv bootargs $bootargs lvds_panel=0; fi; "  \

            "fatload mmc 1:1 ${loadaddr} ${kernel}; "           \

            "fatload mmc 1:1 ${fdt_addr} ${fdt_file}; "         \

            "bootz ${loadaddr} - ${fdt_addr};\0"                \

        "bootcmd=run bootcmd_mmc\0"

View solution in original post

0 Kudos
3 Replies
1,680 Views
b36401
NXP Employee
NXP Employee

Also you may try to add "saveenv" command after "setenv" one.

Have a great day,

Victor

0 Kudos
1,681 Views
PaulDeMetrotion
Senior Contributor I

I fixed this issue! Instead of having the setexpr and if statements as seperate lines, I added them to the bootcmd_mmc line. This resulted in the desired effect of appending the bootargs line based on the GPIO setting.

        "bootargs=console=ttymxc2,115200n8 "                    \

            "root=/dev/mmcblk2p2 rootwait rw ${ip_config}\0"    \

        "bootcmd_mmc= "                                         \

            "setexpr tmpvar *20ac000 '&' 00000100; "            \

            "if test ${tmpvar} != 0; then "                     \

                "setenv bootargs $bootargs lvds_panel=1; else " \

                "setenv bootargs $bootargs lvds_panel=0; fi; "  \

            "fatload mmc 1:1 ${loadaddr} ${kernel}; "           \

            "fatload mmc 1:1 ${fdt_addr} ${fdt_file}; "         \

            "bootz ${loadaddr} - ${fdt_addr};\0"                \

        "bootcmd=run bootcmd_mmc\0"

0 Kudos
1,680 Views
BiyongSUN
NXP Employee
NXP Employee

you can take the usb serial download mode switching as reference.

But replace the "is_boot_from_usb" by the fuction for GPIO reading.

rel_imx_3.10.53_1.1.0_ga/uboot-imx$ grep -rn is_boot_from_usb .

./common/main.c:21:#ifdef is_boot_from_usb

./common/main.c:350:#ifdef is_boot_from_usb

./common/main.c:351:    if (is_boot_from_usb()) {

./common/main.c:389:#ifdef is_boot_from_usb

./common/main.c:390:    if (is_boot_from_usb()) {

./arch/arm/include/asm/arch-mx6/imx-regs.h:972:#define  is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))

./arch/arm/include/asm/arch/imx-regs.h:972:#define  is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))

0 Kudos