There are detailed instructions for building kernel in document Tegra Linux Driver Package Development Guide 27.1 Release that you may download from NVIDIA developer site. See section Advanced Setup and Customization/Building the NVIDIA Kernel.
This R27.1 is for TX2, for TX1 I don’t know if the equivalent document for R24 has same information.
You may have to translate some TX2 specific into TX1.
[EDIT: for TX1: http://developer.nvidia.com/embedded/dlc/l4t-documentation-24-2-1. See this thread: https://devtalk.nvidia.com/default/topic/1008437/jetson-tx1/how-to-compile-and-install-nvidia-kernel-on-tx1/post/5146630/#5146630]
Once you’ll be able to run your own kernel, the easiest way might be to add a sysfs node that you would just read from userland as a file and the read would provide the string. The node is just like a file, you could access it from shell with cat.
You may find many examples of adding a sysfs node in kernel from the web.
On read (by a user application), the kernel would call kernel function tegra_chip_uid(), and convert result from kernel space to userland into read buffer.
[EDIT: It is also convenient in recent L4T versions to use sysfs.]