In D2WD, GPIO0 is always HIGH

arespno
Posts: 9
Joined: Sat Feb 20, 2016 12:19 pm

In D2WD, GPIO0 is always HIGH

Postby arespno » Tue Jun 20, 2017 7:19 am

This is a sample that has been modified from the "blink":

Code: Select all

/* Blink Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"

/* Can run 'make menuconfig' to choose the GPIO to blink,
   or you can edit the following line and set a number here.
*/
#define BLINK_GPIO CONFIG_BLINK_GPIO

void blink_task(void *pvParameter)
{
    /* Configure the IOMUX register for pad BLINK_GPIO (some pads are
       muxed to GPIO on reset already, but some default to other
       functions and need to be switched to GPIO. Consult the
       Technical Reference for a list of pads and their default
       functions.)
    */
    gpio_pad_select_gpio(BLINK_GPIO);
    /* Set the GPIO as a push/pull output */
    gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
    gpio_pad_select_gpio(GPIO_NUM_0);
    gpio_set_direction(GPIO_NUM_0, GPIO_MODE_INPUT);
    while(1) {
        gpio_set_level(BLINK_GPIO, gpio_get_level(GPIO_NUM_0));
        vTaskDelay(50 / portTICK_PERIOD_MS);
        /* Blink off (output low) */
//        gpio_set_level(BLINK_GPIO, 0);
//        vTaskDelay(1000 / portTICK_PERIOD_MS);
        /* Blink on (output high) */
//        gpio_set_level(BLINK_GPIO, 1);
//        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}

void app_main()
{
    xTaskCreate(&blink_task, "blink_task", 512, NULL, 5, NULL);
}
When useing D0WDQ6 and D0WD, pressed button, LED turns off, released button, LED lights up.
When using d2wd, LED always lights up.
Why is that?

Thanks.

PS:
I measure the voltage of the GPIO0 with a multimeter.
After restarting, in D0WDQ6 and D0WD, the voltage of the GPIO0 is 3.0V,
in D2WD, the voltage of the GPIO0 is 3.3V.
When pressed button, the voltage is 0.0V in D0WDQ6 and D0WD, the voltage is still 3.3V in D2WD.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: In D2WD, GPIO0 is always HIGH

Postby ESP_Angus » Mon Jun 26, 2017 3:38 am

Hi arespno,

Thanks for reporting this. There was a bug in the bootloader image generation which caused GPIO0 to be enabled in the GPIO Matrix as a SPI WP pin and that pin's default output drive mode was holding it high. (This happens only on -D2WD because that chip remaps its SPI flash pins via efuse. The -D2WD chip doesn't actually use GPIO0, but the bug causes that pin to be enabled incorrectly.)

We have a fix in the pipeline for release shortly. After it's available, rebuilding and reflashing the bootloader will fix the issue.

In the meantime, you can add this line of code at the time you configure GPIO0:

Code: Select all

REG_WRITE(GPIO_FUNC0_OUT_SEL_CFG_REG, SIG_GPIO_OUT_IDX);
... the line can be left in after the fix is merged, it won't cause any problems by being there.

Angus

arespno
Posts: 9
Joined: Sat Feb 20, 2016 12:19 pm

Re: In D2WD, GPIO0 is always HIGH

Postby arespno » Mon Jun 26, 2017 8:10 am

It works fine.
Thanks for your answer, Angus.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: In D2WD, GPIO0 is always HIGH

Postby ESP_Angus » Tue Jun 27, 2017 12:25 am

This fix is in the IDF master branch as of commit c26baeb610d2bb764d5d9c4cb02c83e4a28f327c, and will be in the forthcoming v2.1 release.

arespno
Posts: 9
Joined: Sat Feb 20, 2016 12:19 pm

Re: In D2WD, GPIO0 is always HIGH

Postby arespno » Tue Jun 27, 2017 3:24 am

The problem is solved with the commit c26baeb610d2bb764d5d9c4cb02c83e4a28f327c.
Thanks for updating.

Who is online

Users browsing this forum: No registered users and 192 guests