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?
Solved! Go to Solution.
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"
Also you may try to add "saveenv" command after "setenv" one.
Have a great day,
Victor
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"
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)))