Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

factory reset by GPIO pin

BixelBixel Los Angeles

How can I set up the GPIO pin 0 to factory reset?

I've added
MGOS_ENABLE_GPIO_API: 1
to my mos.yaml file.

On my conf_vendor.json file, I've added

"debug": {
"enable_prompt": true,
"factory_reset_gpio": 0,
"level": 2,
"mbedtls_level": 0,
"stderr_uart": 0,
"stdout_uart": 0
}

but pressing the button for GPIO pin 0 doesn't seem to do anything.

Thanks for your help!

Comments

  • rojerrojer Dublin, Ireland
    edited February 9

    you need to boot with GPIO0 low. however, assuming you are using ESP8266 or ESP32, choosing GPIO0 for this is not a good idea because pulling it low during boot will get you into boot loader. choose another pin.

  • BixelBixel Los Angeles

    Thanks for the tips. So I am currently using ESP32, GPIO pin 25. I've updated my conf_vendor.json file to...

    "debug": {
    "enable_prompt": true,
    "factory_reset_gpio": 25,
    "level": 2,
    "mbedtls_level": 0,
    "stderr_uart": 0,
    "stdout_uart": 0
    }

    With the factory-reset-button held down, I reset the device. It still doesn't seem to be factory resetting though.

  • rojerrojer Dublin, Ireland

    config's top-level entity should be an object
    in other words, it should be:

    {
      "debug": {
        ...
      }
    }
  • BixelBixel Los Angeles
    edited February 10

    Here's the entire conf_vendor.json file. I only pasted the "debug" section of the array.

    {
      "debug": {
        "enable_prompt": true,
        "factory_reset_gpio": 25,
        "level": 2,
        "mbedtls_level": 0,
        "stderr_uart": 0,
        "stdout_uart": 0
      },
      "mqtt": {
        "server": "**********.iot.us-west-2.amazonaws.com:8883",
        "user": "",
        "pass": "",
        "reconnect_timeout_min": 10,
        "reconnect_timeout_max": 60,
        "ssl_cert": "aws-iot-**********.crt.pem",
        "ssl_key": "aws-iot-**********.key.pem",
        "ssl_ca_cert": "ca-verisign-ecc-g2.crt.pem",
        "clean_session": true,
        "keep_alive": 60,
        "will_topic": "",
        "will_message": "",
        "pub": "bb",
        "sub": "aa"
      },
      "wifi": {
        "sta": {
          "enable": false
        },
        "ap": {
          "enable": true,
          "pass": "******",
          "ssid": "******_??????"
        }
      }
    }
  • rojerrojer Dublin, Ireland

    this is a problem with esp32 build system - it doesn't actually pass variables to the build.
    i'll take a look, thank you!

  • rojerrojer Dublin, Ireland

    no, that's not true. it's just that MGOS_ENABLE_GPIO_API C preprocessor macro is not actually connected to a make variable. other platforms simply define it when building, that's why it works on ESP8266 and CC3200, but ESP32 does not.
    the variable shouldn't be there anyway, i'll clean it up.
    meanwhile, please just remove #if in mgos_sys_config.c

  • BixelBixel Los Angeles
    edited February 10

    Ok thanks rojer. I tried removing the

    #if MGOS_ENABLE_GPIO_API

    #endif

    rebuilt, reflashed, and same procedure as before to no avail. It looks like you're getting close though! Thanks for looking into this.

  • rojerrojer Dublin, Ireland

    ok, then just wait for my change to land. it definitely works now:

    esp32_fs_mount       Total: 113201, used: 32630, free: 80571
    mgos_sys_config_init Factory reset requested via GPIO25
    mgos_sys_config_init Removed conf.json
  • BixelBixel Los Angeles

    ok great! Could you let me know when your changes are pushed?

    Thanks!

  • rojerrojer Dublin, Ireland

    yes, i;ll post here. should be later today.

  • BixelBixel Los Angeles

    Confirm, all seems to be working as expected.

    Thanks Rojer!

Sign In or Register to comment.