Giter Site home page Giter Site logo

cesanta / mongoose-os Goto Github PK

View Code? Open in Web Editor NEW
2.5K 167.0 428.0 45.9 MB

Mongoose OS - an IoT Firmware Development Framework. Supported microcontrollers: ESP32, ESP8266, CC3220, CC3200, STM32F4, STM32L4, STM32F7. Amazon AWS IoT, Microsoft Azure, Google IoT Core integrated. Code in C or JavaScript.

Home Page: https://mongoose-os.com

License: Other

JavaScript 1.89% C 76.78% Makefile 2.49% Shell 0.14% C++ 4.01% Python 6.06% Assembly 7.09% Go 0.97% Batchfile 0.20% HTML 0.22% CMake 0.15%
iot aws aws-iot esp8266 esp32 stm32 cc3200 firmware iot-platform

mongoose-os's Introduction

License Gitter

Mongoose OS - an IoT Firmware Development Framework

  • Over-The-Air firmware updates and remote management - reliable updates with rollback on failures, remote device access infrastructure
  • Security - built in flash encryption, crypto chip support, ARM mbedTLS optimized for small memory footprint
  • Device management dashboard service
  • Supported microcontrollers: CC3220, CC3200, ESP32, ESP8266, STM32F4, STM32L4, STM32F7
  • Recommended dev kits: ESP32-DevKitC for AWS IoT, ESP32 Kit for Google IoT Core
  • Built-in integration for AWS IoT, Google IoT Core, Microsoft Azure, Adafruit IO, generic MQTT servers
  • Code in C or JavaScript
  • Ready to go Apps and Libraries
  • Embedded JavaScript engine - mJS

Trusted and Recommended By:

Docs, Support

Licensing

Mongoose OS is Open Source and dual-licensed:

  • Mongoose OS Community Edition - Apache License Version 2.0
  • Mongoose OS Enterprise Edition - Commercial License

Community vs Enterprise Edition

Community Edition Enterprise Edition
License Apache 2.0 Commercial - contact us
Allows to close end-product's source code Yes Yes
Price Free Paid, see details
Source code & functionality Limited Full
Technical support Community support via Forum and Chat Commercial support by Mongoose OS development team, see details

How to contribute

mongoose-os's People

Contributors

a2800276 avatar alashkin avatar cpq avatar dimonomid avatar duncandrennan avatar edvakf avatar evthewolf avatar headler avatar imax9000 avatar kzyapkov avatar markirb avatar markterrill avatar mattn avatar mpromonet avatar nexgensri01 avatar nikwest avatar nliviu avatar novlean avatar pimvanpelt avatar pkjq avatar qrpp avatar rojer avatar rojer9-fb avatar rtrue983 avatar ruslanvaliullin avatar ryancaicse avatar schmurfy avatar timgates42 avatar victoraldir avatar zserge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongoose-os's Issues

Wifi.status() gives garbage on first run

I'm testing your smart.js code, and I think I found a bug in it. When I first started it up, I tried to get the WiFi status:

smartjs 12040/3456$ Wifi.status()
"�W�?"

I compiled this with the 1.2.0 SDK, and it looks like the bug originally stems from there: when the WiFi station isn't online for whatever reason, wifi_station_get_connect_status() returns -1 (well, it's an u8 so actually 255.) I'll see if I can get that fixed or documented in the SDK, but in general, maybe the select statement in v7_esp.c, Wifi_status could use a default case so it doesn't return uninitialized memory when the WiFi status value is something weird?

Support for firmware larger than 512k on ESP8266?

Is it possible to support a larger firmware size on the ESP8266? I keep running into the following issue when trying to add custom features to the firmware:

ld: build/smartjs.out section '.irom0.text' will not fit in region 'irom0_0_seg'

I have a 4MB flash on my ESP8266 and I believe the ESP8266 can access 1MB of Flash at a time, is it possible to have a 1024k firmware size? What files/parameters do I need to change?

v7_uart.h is missing

Building platform/esp8266 yields the following error:

$ ./make.sh
make: *** No rule to make target `user/v7_uart.h', needed by `build/user_main.o'.  Stop.

Demo function fails in posix platform

I tried to run the demo function in posix platform but the execution fails:

smartjs 1928036352/118608$ demo()
Initializing demo data source 
Starting temperature push demo in background, type Debug.mode(1) to see activity 
Exec error:{"message":"[Debug] is not defined"}
   at: [function demo()]
   at: [function startDemo()]
   at: [function demo()]

Docker container reference seems to be broken in 'make.sh'

In the platforms/esp8266/make.sh file, the referenced docker container is:

docker.cesanta.com:5000/esp8266-build-oss:1.3.0-cesanta

It seems that the corresponding docker repository is empty:

Unable to find image 'docker.cesanta.com:5000/esp8266-build-oss:1.3.0-cesanta' locally
Pulling repository docker.cesanta.com:5000/esp8266-build-oss
Error: image esp8266-build-oss:1.3.0-cesanta not found

Changing the make.shfile seems to fix the issue:

SDK=cesanta/esp8266-build-oss

Is the container located at https://hub.docker.com/r/cesanta/esp8266-build-oss/ still valid for build?

metrics database engine shows devices from other projects

I've opened the metric database panel (https://dashboard.cesanta.com/#/db) with the default project selected.
When I query for {src=~".*"} I get values for devices in Demo project but not in Default project:

[[{"__name__":"temperature","src":"//api.cesanta.com/d/fakedevice02"},[[1443628202260,19.3]]],[{"__name__":"temperature","src":"//api.cesanta.com/d/fakedevice01"},[[1443628201987,13.94]]],[{"__name__":"temperature","src":"//api.cesanta.com/d/fakedevice03"},[[1443628202572,27.03]]]]

File.list returns same results

File.list returns always the same list:

File.list('/var')

"gpio.js","I2C.js","init.js","MC24FC.js","MC24FC_test.js","MCP9808.js","MCP9808_test.js","MPL115A1.js","smart.js","sys.json","user.json"]

File.list('/etc/')

"gpio.js","I2C.js","init.js","MC24FC.js","MC24FC_test.js","MCP9808.js","MCP9808_test.js","MPL115A1.js","smart.js","sys.json","user.json"]

Version command

Would be nice to have a Firmware.version() function in the JavaScript API. The function should return the installed Smart.js version.

Http client tries to alloc 1.3GiB of RAM

I try to get some code up and running that fetches some JSON from a server and turns on or off a LED according to the retrieved value. This is my init.js:

Debug.mode(1)

function doStuff() {
    var url="http://meuk.spritesserver.nl/lighttest.php";
    Http.get(url, function(d, e) {
        print("doStuff http req done.");
        if(e) {
            print("Error: "+e);
        } else {
            print("Got "+d);
            res=eval(d);
            GPIO.write(2, res.led);
        }
        setTimeout(doStuff, 3000);
    });
    print("doStuff done.");
}

Wifi.setup("testjmd", "mypassword");
print("Call doStuff to kick off process");

If I now call doStuff(), instead of turning on or off the LED, the Smart.js interpreter traps on a malloc fail:

smartjs 7864/3072$ No heap available, failed to malloc 1394634784

Trap 9: pc=0x40100a2a va=0x726562
waiting for gdb

I'll leave the URL I called up, so you can do tests if you need to do so. I get this result both when the webserver returns a 404, as well as when it returns a small JSON file. FYI, this is the GDB backtrace when it retrieves a 404; I presume the effect on the JSON file is the same but I couldn't be bothered to attach GDB for that.

#0  0x40100a2a in ?? ()
#1  0x40100996 in vPortFree ()
#2  0x40100a11 in pvPortRealloc ()
#3  0x402214e8 in realloc (ptr=0x3fff9ca0, size=size@entry=887) at user/libc_replacements.c:52
#4  0x4022363f in mbuf_resize (a=a@entry=0x3fff4dc8, new_size=887) at user/v7.c:2411
#5  0x402236ec in mbuf_trim (mbuf=mbuf@entry=0x3fff4dc8) at user/v7.c:2419
#6  0x402266ca in v7_gc (v7=0x3fff4d68, full=<error reading variable: can't compute CFA for this frame>, 
    full@entry=1) at user/v7.c:8598
#7  0x402214f4 in realloc (ptr=0x3fff9ca0, size=1394634762) at user/libc_replacements.c:54
#8  0x4022374a in mbuf_insert (a=a@entry=0x3fff4dc8, off=off@entry=887, buf=buf@entry=0x0, 
    len=1394633875, len@entry=<error reading variable: can't compute CFA for this frame>)
    at user/v7.c:2438
#9  0x40226a48 in embed_string (m=m@entry=0x3fff4dc8, offset=887, 
    p=0x3fff97c7 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL /lighttest.php was not found on this server.</p>\n<hr>"..., len=len@entry=1394633869, 
    zero_term=<error reading variable: can't compute CFA for this frame>, zero_term@entry=1, 
    unesc=<error reading variable: can't compute CFA for this frame>, unesc@entry=0) at user/v7.c:7645
#10 0x40226b6c in v7_create_string (v7=0x3fff4d68, 
    p=<error reading variable: can't compute CFA for this frame>, 
    p@entry=0x3fff97c7 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL /lighttest.php was not found on this server.</p>\n<hr>"..., len=1394633869, own=own@entry=1) at user/v7.c:7690
#11 0x40232150 in http_disconnect_cb (arg=<error reading variable: can't compute CFA for this frame>)
    at user/v7_http_client.c:115
#12 0x40251b1e in ?? ()
#13 0x40251b1e in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Http.get unusable for urls containing an IP Address

I am unable to use the Http.get API in the Alpha 2.1 to access servers using their ip address. Servers that rely on DNS to resolve the hostname into an IP address work fine, but when trying to access a server via IP address directly (http://192.168.1.xxx) the callback is never called.

Using the Http.request API that is in the latest codebase, I am able to access urls that contain IP addresses, however, the Http.request function eats memory and I can only make 10 or so calls before I am out of memory

Can't access dashboard

I'm trying to access the online dashboard.
After I click the "Sign In with Github" button a white page with this message appears: "Error setting up new user: context deadline exceeded".

Examples

Some examples are needed.
Also, the integration with the cloud platform, following the instructions in the repo does not seem to work...

Posix platform build fails for arm architecture

I'm trying to build smart.js for the posix platform and arm architecture but it fails:

fedy2@guendalinaXII ~/esp/smart.js/platforms/posix $ sh makearm.sh 
//bin/bash: line 0: cd: /cesanta/smartjs/platforms/posix: No such file or directory

Demo function overflow heap when wi-fi not configured in ESP

I've run the demo function without configuring the Wifi and I got this error:

Initializing demo data source 
Starting temperature push demo in background, type Debug.mode(1) to see activity 
"disp_task"(stack_size = 392,task handle = 3fff58f0) overflow the heap_size.

Maybe a check and a "Wifi not configured" error message would be better.

Support for a serverless and/or peer-to-peer architecture

In one use case of IoT we have a need for a server for remote device management, however, I think this will be a minority usage.

The most usage will be for IoT devices to be as self-contained as possible, without the need to rely on anything outside of itself. Besides, as IoT reaches its peak, servers are going to get hammered and some people/companies may wish to avoid this altogether. It is also more secure if there is less reliance on something external.

There are a few ways to achieve this:

  1. Bundle the server with the client. Since this is Node.js, this should not be too difficult. It may increase the size of the storage required but it would be another option to have everything self-contained, including the datastore. In fact, there may not even be a need for this extra server code (similar to https://webtask.io/docs/how).
  2. Give each IoT device the ability to talk directly to other devices via P2P technology e.g. Bittorrent. This would also eliminate the need for a central server. IoT devices can fetch bits of data from other devices and maybe each device has a copy of the other devices settings. This way even if one IoT device fails, the data is still secure.

Would be great to get your thoughts on this!

flashnchips: no errors when serial connection fails

Erroneously I've opened two instances of Flash'n'Chips. When I try to flash the device on the second instance pressing the "Flash firmware" button I don't get any feedback.
In the log I can see the "DEBUG: connectSerial: INTERNAL: Failed to open".
An error message in the UI would be useful.

how to compile with Regex support (ESP8266)

Does the ESP8266 build of smart.js support regex? I compiled my own smart.js, and I have the following defined

V7_ENABLE__RegExp 1 

however, whenever I try to create a regular expression I get the following message

Exec error:{"message":"Regexp support is disabled"}

Posix platform console crashes after closing empty file

I've opened an empty file, read it all and then closed it. After the close command the console crashes:

smartjs 1928036352/118496$ var f = File.open('empty.txt')
{}
smartjs 1928036352/118520$ var d = f.readAll();

smartjs 1928036352/118488$ f.close();
*** Error in `./smartjs': double free or corruption (!prev): 0x00000000021bd290 ***
Aborted
fedy2@guendalinaXII ~/esp/smart.js/platforms/posix/bin $ 

ESP8266 platform build fails

I've pulled the last version from the git repository and run sh make.sh but I get:

fedy2@guendalinaXII ~/esp/smart.js/platforms/esp8266 $ sh make.sh 
make: *** No rule to make target `../../src/clubby.js', needed by `firmware/0x6d000.bin'.  Stop.

Roadmap

This really interests me, as my least favorite part of working with these devices is writing C.

I'm wondering what the roadmap looks like? I have a few things off the top of my head that I'd like to see:

  • CoAP client
  • CoAP server
  • decouple the cloud functionality from the core? If I pick up Smart.js, I won't use/need Cesanta's servers.

I'm also curious how well the custom JS engine will withstand the test of time. it's been tried before with things like Espruino, and the result was/is pretty painful. I think part of the issue in that case was a non-JS developer writing a JS API. Object.emit()? the Tessel team threw up their hands at this nonsense and decided to just run Linux. The other issue of course is that JS developers come from the browser and NodeJS and expect their favorite functions to be there. What might be a cool idea would be to transpile from everyday JS to Smart.js-speak.

Keep hacking! This is exciting stuff.

Cloud.store command fails

I've tried the Cloud.store command from the console but I get back an error message:

smartjs 29464/2388$ Cloud.store('temperature', 36.6)
Exec error:{"message":"[Cloud] is not defined"}
smartjs 29464/2388$ 

smart.js build for posix platform fails

I've tried to build the smart.js for posix platform and ARM architecture but the build fails:

fedy2@guendalinaXII ~/esp/smart.js/platforms/posix $ sh makearm.sh 
Unable to find image 'docker.cesanta.com:5000/eabihf-arm-build:latest' locally
latest: Pulling from eabihf-arm-build

eeb365049982: Pull complete 
63dd1fb7de4f: Pull complete 
22eedc530341: Pull complete 
95757659f2bd: Pull complete 
de14382e9617: Pull complete 
d12b786894eb: Pull complete 
5c2f1b97b1a5: Pull complete 
bc07cbc8c626: Pull complete 
e58fd13c669a: Pull complete 
981fea4696c5: Already exists 
6071b4945dcf: Already exists 
5bff21ba5409: Already exists 
e5855facec0b: Already exists 
8251da35e7a7: Already exists 
Digest: sha256:7d5ffc336b7876fb552c825970f96faebfb5c7133252006ae0ab110482623a82
Status: Downloaded newer image for docker.cesanta.com:5000/eabihf-arm-build:latest
//bin/bash: line 0: cd: /cesanta/smartjs/platforms/posix: No such file or directory

Http.get with master build

Hi,

I am using the build from master 40892b7. It seems my esp8266 is connecting to my router but when I try the simplest Http.get example, it simply doesn't work. Any idea how to debug it?

smartjs 11808/1056$ Wifi.status()
got ip

smartjs 11808/1056$

Http.get("http://96.126.98.124", function(data, error) {  if (error) {    print("error ", error);  } else {    print("my ip is ", JSON.parse(data).ip);  }});

true
smartjs 8864/972$

then, no output is printed on Smart.js flashing tool.

The IP belongs to jsonip.com, as when I use a domain name, I got "cannot resolve" error.

ESP8266 Coredump stopped by watchdog

I'm trying to use the coredump feature on an ESP8266. The Base64 characters are written to UART, however after a few seconds the watchdog seems to kick in and resets the MCU. I get "cause ::4" reset , indicating watchdog reset. Any way to prevent this reset ?
Really hoping to use this extremely interesting feature for debugging some other issues.

flashnchips: unknown chars after ESP flash

After the ESP8266 01 has been flashed I get this message in console:

--- flashed successfully
--- connected
load 0x40100000, len 31868, room 16 
??E??ab?C????DÇ?h????????????b???btA?DÇ?h??C???H?b??E??hb?A?E???�??Cr��Device id: //api.cesanta.com/d/XXXXXX
Device psk: XXXXXXXX 
Cloud: //api.cesanta.com 

I've obfuscated the id and the psk.

Flashnchips: "Failed to merge flash filesystem"

I've flashed my ESP8266 01 a first time successfully but I got no responses from the live console.
I've decided to flash it a second time but I get the following error message "Failed to merge flash filesystem".
What I can do about?

I'm using an ESP8266 01, connected trough a FT232 adapter. Flash'n'Chips is running under Windows 7 x64.

Linux build

Hi, is it possible to evaluate your interpreter without any extra hardware, i.e. run it on a linux machine?

[Cloud] is not defined

Scanning nets 
Device id: //api.cesanta.com/d/dev_50648 
Device psk: psk_0805 
Cloud: //api.cesanta.com 

smartjs 29888/2244$ Joining MY_WiFi 
Cloud.store('temperature', 36.6)
Exec error:{"message":"[Cloud] is not defined"}
smartjs 29392/2364$ 

Websocket support?

if i flash my esp8266 with smart.js firmware, can i use it like "client can connectable websocket server".
for example
"....

<script type="text/javascript"> var ws = new WebSocket("ws://localhost:8080/websockets"); ws.onopen = function(something) { function something(something); } ...." small html page including above code can be connect ws server. can i use <script type="text/javascript"> .... <\scprit> code in my esp8266 flashed with smart.js?

Compilation troubles

with sh make.sh i'm getting Makefile:18: *** Use make.sh to build project within docker container. To build against locally installed ESP SDK define SDK_FLAVOUR (with RTOS or OSS value) enviroment variable. Stop.
with sh make.sh RTOS :

Unable to find image 'docker.cesanta.com:5000/esp8266-build-rtos:1.2.0-cesanta-r4' locally
1.2.0-cesanta-r4: Pulling from docker.cesanta.com:5000/esp8266-build-rtos
a8c34f0f9db9: Pull complete 
46745474f5aa: Pull complete 
7163ab7a738c: Pull complete 
3885a86c7f89: Pull complete 
fee9f8ef6b54: Pull complete 
00603c7e53a4: Already exists 
6071b4945dcf: Already exists 
5bff21ba5409: Already exists 
e5855facec0b: Already exists 
8251da35e7a7: Already exists 
09415d9209b6: Already exists 
039ea637f66d: Already exists 
56628a10fdaa: Already exists 
95fd921a6c96: Already exists 
82e9bde453bb: Already exists 
0c2a69e609b2: Already exists 
0f277c74a47a: Already exists 
a53cf678171e: Already exists 
f24ef6cf7338: Already exists 
5ea338a5df36: Already exists 
Digest: sha256:53f1eb6cd4829df09b0918158bf11f18cedd3542d86c8f0e050ca1af3a3c5824
Status: Downloaded newer image for docker.cesanta.com:5000/esp8266-build-rtos:1.2.0-cesanta-r4
  CC user/c_sscanf.c -> build/c_sscanf.o
  CC user/dht11.c -> build/dht11.o
  CC user/disp_task.c -> build/disp_task.o
  CC user/disp_task_net_test.c -> build/disp_task_net_test.o
  CC user/esp_coredump.c -> build/esp_coredump.o
user/esp_coredump.c:14:20: fatal error: base64.h: No such file or directory
 #include "base64.h"
                    ^
compilation terminated.
make: *** [build/esp_coredump.o] Error 1

Doesn't connect to AP

print('Hello world');

Wifi.setup('Dlink', 'password');

Wifi.changed(function(status) {
  print('Wifi status changed to ', status);
  if(status == 4) {
    Http.get("http://jsonip.com", function(data, error) {
      if (error) {
        print("error ", error);
      } else {
        print("my ip is ", JSON.parse(data).ip);
      }
    });
  }
});

I'm trying to connect to my WPA2 router but the status never reaches 4.

Build error for platform ESP8266: missing "osdep.h"

Running sh make.sh yields the following error:

$ sh make.sh
  CC user/esp_wifi.c -> build/esp_wifi.o
In file included from user/esp_wifi.c:7:0:
../../src/sha1.h:9:19: fatal error: osdep.h: No such file or directory
 #include "osdep.h"
                   ^
compilation terminated.
make: *** [build/esp_wifi.o] Error 1

better garbage collection for closures?

Running the code below on a NodeMCU board (ESP8266) causes the interpreter to crash at around after calling add around 100 times.
I have tried several different scenarios using closures and they all lead to smart.js crashing. I have not taken a look yet at the code yet to see how closures are handled internally in smart.js

var add = (function () {
    var counter = 0;
    return function () {return counter += 1;}
})();

for(i=0;i<=1000;i++)
{
  console.log(add());
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.