Is it possible to write a custom Firmware for the Fez Raptor?
The easiest thing to do is write native code using RuntimeLoadableProcedures. https://www.ghielectronics.com/docs/50/rlp
The GHI netMF port for the Raptor is not open source so you can’t build or modify it yourself.
You can make your own custom NETMF port for the hardware using the porting kit, but this is a big task.
You might be able to contract GHI to add in specific functionality that you need.
How do I know witch GPIO (pinnr) is on witch socket? Is this documented?
Take a look at the schematic on the resources section of the catalogue
If you really need a custom firmware, you should contact GHI by their consulting services.