Drivers for “peripherals” like camera, display, bluetooth, etc are blobs and run a layer on top of the kernel. This is called Android HAL (Hardware Abstraction Layer).
I think writing drivers from scratch is nearly impossible. I’m not a systems developer, but the people at Mozilla with B2G/FxOS, the people at Canonical with Ubuntu Touch, the people at KDE with Plasma Mobile and the people at Jolla with Sailfish OS, all of them, use the device kernel sources and provide slightly different methods to reuse the blobs:
- FxOS is built over a stripped down Android which, well, “boots to Gecko”, which runs Gaia then
- Ubuntu Touch boots to the Ubuntu rootfs and uses libhybris over a LXC Android container (a kind of chroot?), included as a separate image
- Sailfish OS boots to a GNU rootfs and uses libhybris too
- Pasma Mobile uses libhybris too, I don’t know the internals yet
It may be that these OSes were thought for the global scope, not for a particular device. Libhybris seems to be the only option available for the task. Note that Android blobs are not compiled with GNU C (glibc), but with Bionic, the C library modified by Google for Android (I’m not so technical here because I don’t clearly understand the differences, honestly)
If you want, I can search for some kind of paper I found somewhere in the Internet about Ubuntu Touch architecture in deep.