Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

Sonoff

Hi,
I was trying to develop an app for Sonoff basic for a demo of mongoose os in my company but it won't start.

[Jan  8 21:22:56.454] Fatal exception (28): 
[Jan  8 21:22:56.454] epc1=0x401000ab, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00004028, depc=0x00000000

After restart simply not starting without any logs. This module starts and working with loaded Tasmota but I really want to use MongooseOS for our projects.
Build for Esp8266 1mb
Flashed with mos flash

init.js

load('api_timer.js');
load('api_gpio.js');
load('api_sys.js');
load('api_config.js');
load('api_log.js');
load('api_rpc.js');
load('api_aws.js');
load('api_shadow.js');
load('api_dash.js');

let led_onboard = 13; // Sonoff LED pin
let relay_pin = 12;  // Sonoff relay pin
let spare_pin = 14;  // Sonoff not connected
let button_pin = 0;  // Sonoff push button
let state = {led_onboard: false, relay: false, uptime: 0};  // Device state
let online = false;                               // Connected to the cloud?

// GPIO.set_mode(led_onboard, GPIO.MODE_OUTPUT);
// GPIO.set_mode(relay_pin, GPIO.MODE_OUTPUT);

let reportState = function() {
  Shadow.update(0, state);
};

Timer.set(1000, Timer.REPEAT, function() {
  state.uptime = Sys.uptime();
  state.ram = Sys.free_ram();
  print('online:', online, JSON.stringify(state));
  if (online) reportState();
}, null);

// Set up Shadow handler to synchronise device state with the shadow state
Shadow.addHandler(function(event, obj) {
  if (event === 'UPDATE_DELTA') {
    print('GOT DELTA:', JSON.stringify(obj));
    for (let key in obj) {  // Iterate over all keys in delta
      if (key === 'on') {   // We know about the 'on' key. Handle it!
        state.on = obj.on;  // Synchronise the state
        GPIO.write(led_onboard, state.on);   // according to the delta
      } else if (key === 'relay') {
        state.relay = obj.relay;
        GPIO.write(relay_pin, state.relay);
      } else if (key === 'reboot') {
        state.reboot = obj.reboot;      // Reboot button clicked: that
        Timer.set(750, 0, function() {  // incremented 'reboot' counter
          Sys.reboot();                 // Sync and schedule a reboot
        }, null);
      }
    }
    reportState();  // Report our new state, hopefully clearing delta
  }
});


Event.on(Event.CLOUD_CONNECTED, function() {
  online = true;
  Shadow.update(0, {ram_total: Sys.total_ram()});
}, null);

Event.on(Event.CLOUD_DISCONNECTED, function() {
  online = false;
}, null);

mos.yml

author: mongoose-os
description: A JS-enabled demo Mongoose OS firmware
# arch: PLATFORM
version: 1.0
manifest_version: 2017-05-18
libs_version: ${mos.version}
modules_version: ${mos.version}
mongoose_os_version: ${mos.version}

tags:
  - cloud
filesystem:
  - fs
libs:
  - origin: https://github.com/mongoose-os-libs/boards
  - origin: https://github.com/mongoose-os-libs/gcp
  - origin: https://github.com/mongoose-os-libs/pwm
  - origin: https://github.com/mongoose-os-libs/rpc-loopback
  - origin: https://github.com/mongoose-os-libs/rpc-mqtt
  - origin: https://github.com/mongoose-os-libs/rpc-service-gpio
  - origin: https://github.com/mongoose-os-libs/rpc-service-ota
  - origin: https://github.com/mongoose-os-libs/rpc-service-wifi
  - origin: https://github.com/mongoose-os-libs/spi
  - origin: https://github.com/mongoose-os-libs/vfs-dev-spi-flash
  - origin: https://github.com/mongoose-os-libs/wifi
build_vars:
  FLASH_SIZE: 1048576

I tried without build_vars without success.
Thanks for any suggestions.

Comments

  • rodrmigurodrmigu Fairfax, Virginia

    Hi,

    Never used sonoff with mongoose, not yet, but I will, however looks like we need use this flash option:

    mos flash --esp-flash-params "dout,8m,40m"

    Did you try this one?

    Regards
    Rodrigo

  • Yes, this is default setting, but I tried that manually with no luck.

  • mamuespmamuesp Germany/Northern coast

    At first you should remove APIs and libs you don't need (PWM for example) and try again. The ESP8266 is a very tiny device ... And if you like, post the complete log (here in the forum this is no problem, but in the chat use something like pastebin.com)...

  • rodrmigurodrmigu Fairfax, Virginia

    Just tested my sonoff and it works fine. I also got a lot of these messages you mentioned:

    [Jan 12 16:27:57.497] Fatal exception (28):
    [Jan 12 16:27:57.501] epc1=0x401000ab, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00004028, depc=0x00000000
    [Jan 12 16:27:57.503] Fatal exception (28):
    [Jan 12 16:27:57.505] epc1=0x401000ab, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00004028, depc=0x00000000
    [Jan 12 16:27:57.508] Fatal exception (28):
    [Jan 12 16:27:57.510] epc1=0x401000ab, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00004028, depc=0x00000000
    [Jan 12 16:27:57.513] Fatal exception (28):
    [Jan 12 16:27:57.515] epc1=0x401000ab, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00004028, depc=0x00000000
    [Jan 12 16:27:57.515] Fatal exception (28):
    [Jan 12 16:27:57.518] epc1=0x401000ab, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00004028, depc=0x00000000
    

    Just reset the device and it should work ok.

    This is the sonoff flashing output:

    C:\Temp\test>mos flash --esp-flash-params "dout,8m,40m"
    Loaded test/esp8266 version 1.0 (20190112-212342)
    Using port COM4
    Opening COM4 @ 115200...
    Connecting to ESP8266 ROM, attempt 1 of 10...
      Connected, chip: ESP8266EX
    Running flasher @ 0...
      Flasher is running
    Flash size: 1048576, params: 0x0320 (dout,8m,40m)
    Deduping...
    Writing...
         4096 @ 0x0
         4096 @ 0x7000
       720896 @ 0x8000
       131072 @ 0xdb000
         4096 @ 0xfb000
         4096 @ 0xfc000
    Wrote 858896 bytes in 49.34 seconds (136.00 KBit/sec)
    Verifying...
         2304 @ 0x0
         4096 @ 0x7000
       717200 @ 0x8000
       131072 @ 0xdb000
         4096 @ 0xfb000
          128 @ 0xfc000
    Booting firmware...
    All done!
    

    Regards
    Rodrigo

Sign In or Register to comment.