esp8266 GPIO input configuration

The following code, when used in user_init() will enable the internal pullup on GPIO0 and read it’s value. Unfortunately GPIO0 (and GPIO2) when held low at boot put the device into a non-running mode (firmware update), I’ve also been unsuccessful in using the internal pulldowns on these pins. This means these pins can not be used for user mode selection at boot, using the internal pullup/down resistors. And unfortunately, those are the only GPIOs available on the simplest modules. It maybe possible if an external pulldown is installed.

gpio_init();
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
PIN_PULLUP_EN(PERIPHS_IO_MUX_GPIO0_U);
os_delay_us(10000);
int config = GPIO_INPUT_GET(0);//GPIO_ID_PIN(PERIPHS_IO_MUX_GPIO0_U));
char buffer[30];
os_sprintf(buffer,"config: %d",config);

This is a continuation of my notes on the esp8266 microcontroller, you can find a complete list of my esp8266 posts here