How should I request and set GPIO using customized u-boot

Hello,

Recently I was trying to set a GPIO value using u-boot. I followed the NVIDIA Tegra Linux Driver Package Development Guide and I was able to build the u-boot system.

1. Modifying the source code:

I added the gpio_request(480, “GPIO_EXP0”) and gpio_direction_output(480, 1) as well as the debug prints in

tegra_board_init(void) and tegra_pcie_board_init(void)

under file:

/u-boot/board/nvidia/p2771-0000/p2771-0000.c

which is the only file that is board related in when I build the u-boot with config in the guide.

2. Flash to device using ‘sudo ./flash.sh -k kernel elroy-usb3 mmcblk0p1’ command.

However, I neither found any debug output during TX2 booting, nor I had found any gpio480 information under ‘/sys/class/gpio’ folder, so I want to ask:

  1. Am I modifying the correct file or using the correct function?
  2. Are rebuilt u-boot binaries been flashed to the device and used by the device?

Many thanks for the reply and help.

hello xiaoyangins,

  1. Am I modifying the correct file or using the correct function?
    yes
  1. Are rebuilt u-boot binaries been flashed to the device and used by the device?
    had you change your device name to ‘elroy-usb3’ ?
    you should saw debug prints in your u-boot message after replace the u-boot.bin.

moreover,
please notice that you should replace the u-boot.bin with yours.
$OUT/bootloader/t186ref/p2771-0000/500/u-boot.bin

and flash the device properly
sudo ./flash.sh -r -k kernel jetson-tx2 mmcblk0p1