Please refer our article on GPIO for Linux.
Assuming you intend to control pin 15 of X27 the
echo 15 > /sys/class/gpio/export is wrong.
There are several numbers/names associated with a given signal.
For an Apalis iMX6 they would be:
Ixora connector X27: pin 15
Ixora schematic signal name: GPIO3
Apalis module X1 connector name/pin number: GPIO3 / 5
SOC pin name / GPIO function name: NAND_DATA06 / GPIO2_IO06
Linux GPIO number: 38
These can be found out from the carrier board and module datasheet. The Linux pin number can then be found here.
For the Apalis iMX6 we run the script
/usr/bin/gpio-export.sh at boot, thus GPIO1 - GPIO4 and GPIO8 are already exported.
root@apalis-imx6:~# echo "out" > /sys/class/gpio/gpio38/direction
root@apalis-imx6:~# echo 1 > /sys/class/gpio/gpio38/value
root@apalis-imx6:~# cat /sys/class/gpio/gpio38/value
Note that the i.MX 6 by default cannot read back the value of a gpio which is configured as output. You could enable this feature by setting the SION bit in the MUX config in the device tree. However it is probably easier to keep track of the last state written in your software.