[beagleboard] How to build Os to beaglebone with hardcoding some of the GPIOs of beaglebone?

What ? Could you possibly ask a more obscure question ?

When I refer, Beaglebone Black P8 Header, the GPIO 38, 39 (GPIO1[6], GPIO1[7]) are having note as "Used on Board (Group: pinmux_emmc2_pins). There are more other PINs having same note.

The bolded text in the quote above should make it obvious as to why your attempt as using these pins as gpio’s fails. They’re in use, and whats more, they’re in use by the eMMC interface is seems.

With older 3.8.x kernels is was possible to disable the eMMC by removing, or commenting out loading the appropriate device tree file in uEnv.txt. Then one could use the pin otherwise assigned to the eMMC how they saw fit. One thing to note however. The hardware is still physically connected, so it could be a bad idea to use some, or all of the pins other than how they’re meant to be used. For this, you would need to consult with one of the community members whose expertise with electronics is greater than mine.

With current 4.1.x kernels, I’d assume the above procedure has not changed much, if at all. But I am unsure. As I have not had reason to check / test this.