Building a Modern IoT Security Stack: From Source to Firmware