
Here I show how to set a GPIO LED for a heartbeat trigger in the Zynq platform. The IO is located in the PS side, and it is physically available in the IO Cape Board of Zturn board from MYIR.
For a simple LED with a heartbeat controlled by a uC, you will have to configure the IO using registers, probably to configure for GPIO, then the direction, pullup register, etc. Sometimes even enabling a clock tree to the GPIO. And for the heartbeat, you will have to have a timer or a clock divider to get the timing right and some logic to implement the heartbeat effect.
BUT in PS with Linux present in the Zynq platform, we just need to use the LED GPIO framework, edit the Linux device tree, compile it, and bang.
In my case there is a device tree source called zynq-zturn.dts in linux-xlnx/arch/arm/boot/dts . My Linux source code is linux-xlnx. The add to the source is:
usr_ledmike {
label = "usr_ledmike";
gpios = <&gpio0 11 1>;
default-state = "off";
linux,default-trigger = "heartbeat";
};
at
&ps7_axi {
gpio-leds {
compatible = "gpio-leds";
usr_ledmike {
label = "usr_ledmike";
gpios = <&gpio0 11 1>;
default-state = "off";
linux,default-trigger = "heartbeat";
};
};
};
We compile with:
linux-xlnx$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- zynq_zturn_defconfig
linux-xlnx$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- uImage
linux-xlnx$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- dtbs
then in the SD card I replace the Kernel and device tree binary with:
maikon@nasa:~/MYIR/Z-TURN_V12_20171030/04-Linux_Source/Kernel/newlinux/linux-xlnx$ scp arch/arm/boot/uImage root@192.168.0.95:/mnt/mmcblk0p1/
maikon@nasa:~/MYIR/Z-TURN_V12_20171030/04-Linux_Source/Kernel/newlinux/linux-xlnx$ scp arch/arm/boot/dts/zynq-zturn.dtb root@192.168.0.95:/mnt/mmcblk0p1/devicetree.dtb
Note the .dtb is renamed.
then after the reboot the heartbeat will be there showing and in:
Z-turn# ls -l /sys/class/leds
lrwxrwxrwx 1 root root 0 Jan 1 00:00 usr_ledmike -> ../../devices/amba.1/gpio-leds.2/leds/usr_ledmike