Browser-based firmware generator
-
MyFactory?
-
Sorry for the silence. My ISP is having trouble, and I've been mostly offline. I'm sending this message over crappy 3G on a phone.
Update
- New 'Code' view that shows what the generated code will look like before having to download it. I'm not sure I like this - I would prefer having no mention of code on the UI at all - but it's worth experimenting with. Certainly makes things easy at dev time.
- A migrations process, so that I don't have to ask you to delete your existing network, as I have been doing. Migrations will now move your local copy of the data to the latest version automatically, without any manual intervention, if there have been any changes in the data format.
That's all I have for now. I'll have more once my connectivity issues are fixed.
-
I've hit a little bit of a wall, and need help to proceed.
I created a NRF24L01 network in the UI, and tried to flash the default serial gateway code to an Arduino Pro Mini 3.3v/8Mhz. There are no sensors configured on the gateway. I tried to flash the SecurityPersonalizer on the device, and it worked perfectly, and gave a happy sounding serial output. (Yay!) However, when I flash the main gateway sketch, I get a 'not enough memory' error.
Sketch uses 25,792 bytes (79%) of program storage space. Maximum is 32,256 bytes. Global variables use 2,204 bytes (107%) of dynamic memory, leaving -156 bytes for local variables. Maximum is 2,048 bytes. processing.app.debug.RunnerException: Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint. at cc.arduino.Compiler.size(Compiler.java:339) at cc.arduino.Compiler.build(Compiler.java:159) at processing.app.SketchController.build(SketchController.java:641) at processing.app.Editor$BuildHandler.run(Editor.java:1782) at java.lang.Thread.run(Thread.java:745) Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.For reference, the generated gateway sketch is as follows:
// Message signing #define MY_SIGNING_SOFT #define MY_SIGNING_SOFT_RANDOMSEED_PIN 7 #define MY_SIGNING_REQUEST_SIGNATURES // load user settings #include "config.h" // load MySensors library #include <MySensors.h> // load NodeManager library #include "NodeManager.h" // create a NodeManager instance NodeManager nm; // before void before() { // setup the serial port baud rate Serial.begin(9600); nm.before(); } // presentation void presentation() { // call NodeManager presentation routine nm.presentation(); } // setup void setup() { // call NodeManager setup routine nm.setup(); } // loop void loop() { // call NodeManager loop routine nm.loop(); } // receive void receive(const MyMessage &message) { // call NodeManager receive routine nm.receive(message); } // receiveTime void receiveTime(unsigned long ts) { // call NodeManager receiveTime routine nm.receiveTime(ts); }and the associated config.h is:
#ifndef config_h #define config_h /********************************** * Sketch configuration */ #define SKETCH_NAME "Gateway" #define SKETCH_VERSION "1.0" //#define MY_REPEATER_FEATURE /********************************** * MySensors node configuration */ // General settings #define MY_BAUD_RATE 9600 //#define MY_DEBUG // NRF24 radio settings #define MY_RADIO_NRF24 #define MY_RF24_ENABLE_ENCRYPTION #define MY_RF24_CHANNEL 76 #define MY_RF24_PA_LEVEL RF24_PA_LOW //#define MY_DEBUG_VERBOSE_RF24 // Serial gateway settings #define MY_GATEWAY_SERIAL /*********************************** * NodeManager configuration */ // if enabled, enable debug messages on serial port //#define DEBUG 1 #define POWER_MANAGER 0 #define BATTERY_MANAGER 0 // if enabled, allow modifying the configuration remotely by interacting with the configuration child id #define REMOTE_CONFIGURATION 1 // if enabled, persist the configuration settings on EEPROM #define PERSIST 1 // if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage #define BATTERY_SENSOR 1 // if enabled, send a SLEEPING and AWAKE service messages just before entering and just after leaving a sleep cycle and STARTED when starting/rebooting #define SERVICE_MESSAGES 1 // Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_MQ, SENSOR_ML8511, SENSOR_ACS712, SENSOR_RAIN_GAUGE #define MODULE_ANALOG_INPUT 0 // Enable this module to use one of the following sensors: SENSOR_DIGITAL_INPUT #define MODULE_DIGITAL_INPUT 0 // Enable this module to use one of the following sensors: SENSOR_DIGITAL_OUTPUT, SENSOR_RELAY, SENSOR_LATCHING_RELAY #define MODULE_DIGITAL_OUTPUT 0 // Enable this module to use one of the following sensors: SENSOR_DHT11, SENSOR_DHT22 #define MODULE_DHT 0 // Enable this module to use one of the following sensors: SENSOR_SHT21 #define MODULE_SHT21 0 // Enable this module to use one of the following sensors: SENSOR_SWITCH, SENSOR_DOOR, SENSOR_MOTION #define MODULE_SWITCH 0 // Enable this module to use one of the following sensors: SENSOR_DS18B20 #define MODULE_DS18B20 0 // Enable this module to use one of the following sensors: SENSOR_BH1750 #define MODULE_BH1750 0 // Enable this module to use one of the following sensors: SENSOR_MLX90614 #define MODULE_MLX90614 0 // Enable this module to use one of the following sensors: SENSOR_BME280 #define MODULE_BME280 0 // Enable this module to use one of the following sensors: SENSOR_SONOFF #define MODULE_SONOFF 0 // Enable this module to use one of the following sensors: SENSOR_BMP085 #define MODULE_BMP085 0 // Enable this module to use one of the following sensors: SENSOR_HCSR04 #define MODULE_HCSR04 0 // Enable this module to use one of the following sensors: SENSOR_MCP9808 #define MODULE_MCP9808 0 #endifI tried commenting out the first three lines in the gateway sketch (the #defines to do with security personalisation, and the sketch fits, but only barely.
Sketch uses 19,922 bytes (61%) of program storage space. Maximum is 32,256 bytes. Global variables use 1,710 bytes (83%) of dynamic memory, leaving 338 bytes for local variables. Maximum is 2,048 bytes. Low memory available, stability problems may occur.I'm by no means a C/C++ guy (which I why I'm writing this tool ;) ) so I'll need help to fix this. I don't even know where to start looking, since there's the combination of NodeManager and the software signing in the sketch.
Any chance you could look at this, @user2684 and @Anticimex? You could download a copy of the code from the UI if you like. My configuration is an NRF network, and the gateway is the default serial gateway on the UI. I've been using the latest version of the MySensors lib from the development branch on GitHub, and am doing the compilation in the Arduino IDE.
Thanks!
-
I've hit a little bit of a wall, and need help to proceed.
I created a NRF24L01 network in the UI, and tried to flash the default serial gateway code to an Arduino Pro Mini 3.3v/8Mhz. There are no sensors configured on the gateway. I tried to flash the SecurityPersonalizer on the device, and it worked perfectly, and gave a happy sounding serial output. (Yay!) However, when I flash the main gateway sketch, I get a 'not enough memory' error.
Sketch uses 25,792 bytes (79%) of program storage space. Maximum is 32,256 bytes. Global variables use 2,204 bytes (107%) of dynamic memory, leaving -156 bytes for local variables. Maximum is 2,048 bytes. processing.app.debug.RunnerException: Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint. at cc.arduino.Compiler.size(Compiler.java:339) at cc.arduino.Compiler.build(Compiler.java:159) at processing.app.SketchController.build(SketchController.java:641) at processing.app.Editor$BuildHandler.run(Editor.java:1782) at java.lang.Thread.run(Thread.java:745) Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.For reference, the generated gateway sketch is as follows:
// Message signing #define MY_SIGNING_SOFT #define MY_SIGNING_SOFT_RANDOMSEED_PIN 7 #define MY_SIGNING_REQUEST_SIGNATURES // load user settings #include "config.h" // load MySensors library #include <MySensors.h> // load NodeManager library #include "NodeManager.h" // create a NodeManager instance NodeManager nm; // before void before() { // setup the serial port baud rate Serial.begin(9600); nm.before(); } // presentation void presentation() { // call NodeManager presentation routine nm.presentation(); } // setup void setup() { // call NodeManager setup routine nm.setup(); } // loop void loop() { // call NodeManager loop routine nm.loop(); } // receive void receive(const MyMessage &message) { // call NodeManager receive routine nm.receive(message); } // receiveTime void receiveTime(unsigned long ts) { // call NodeManager receiveTime routine nm.receiveTime(ts); }and the associated config.h is:
#ifndef config_h #define config_h /********************************** * Sketch configuration */ #define SKETCH_NAME "Gateway" #define SKETCH_VERSION "1.0" //#define MY_REPEATER_FEATURE /********************************** * MySensors node configuration */ // General settings #define MY_BAUD_RATE 9600 //#define MY_DEBUG // NRF24 radio settings #define MY_RADIO_NRF24 #define MY_RF24_ENABLE_ENCRYPTION #define MY_RF24_CHANNEL 76 #define MY_RF24_PA_LEVEL RF24_PA_LOW //#define MY_DEBUG_VERBOSE_RF24 // Serial gateway settings #define MY_GATEWAY_SERIAL /*********************************** * NodeManager configuration */ // if enabled, enable debug messages on serial port //#define DEBUG 1 #define POWER_MANAGER 0 #define BATTERY_MANAGER 0 // if enabled, allow modifying the configuration remotely by interacting with the configuration child id #define REMOTE_CONFIGURATION 1 // if enabled, persist the configuration settings on EEPROM #define PERSIST 1 // if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage #define BATTERY_SENSOR 1 // if enabled, send a SLEEPING and AWAKE service messages just before entering and just after leaving a sleep cycle and STARTED when starting/rebooting #define SERVICE_MESSAGES 1 // Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_MQ, SENSOR_ML8511, SENSOR_ACS712, SENSOR_RAIN_GAUGE #define MODULE_ANALOG_INPUT 0 // Enable this module to use one of the following sensors: SENSOR_DIGITAL_INPUT #define MODULE_DIGITAL_INPUT 0 // Enable this module to use one of the following sensors: SENSOR_DIGITAL_OUTPUT, SENSOR_RELAY, SENSOR_LATCHING_RELAY #define MODULE_DIGITAL_OUTPUT 0 // Enable this module to use one of the following sensors: SENSOR_DHT11, SENSOR_DHT22 #define MODULE_DHT 0 // Enable this module to use one of the following sensors: SENSOR_SHT21 #define MODULE_SHT21 0 // Enable this module to use one of the following sensors: SENSOR_SWITCH, SENSOR_DOOR, SENSOR_MOTION #define MODULE_SWITCH 0 // Enable this module to use one of the following sensors: SENSOR_DS18B20 #define MODULE_DS18B20 0 // Enable this module to use one of the following sensors: SENSOR_BH1750 #define MODULE_BH1750 0 // Enable this module to use one of the following sensors: SENSOR_MLX90614 #define MODULE_MLX90614 0 // Enable this module to use one of the following sensors: SENSOR_BME280 #define MODULE_BME280 0 // Enable this module to use one of the following sensors: SENSOR_SONOFF #define MODULE_SONOFF 0 // Enable this module to use one of the following sensors: SENSOR_BMP085 #define MODULE_BMP085 0 // Enable this module to use one of the following sensors: SENSOR_HCSR04 #define MODULE_HCSR04 0 // Enable this module to use one of the following sensors: SENSOR_MCP9808 #define MODULE_MCP9808 0 #endifI tried commenting out the first three lines in the gateway sketch (the #defines to do with security personalisation, and the sketch fits, but only barely.
Sketch uses 19,922 bytes (61%) of program storage space. Maximum is 32,256 bytes. Global variables use 1,710 bytes (83%) of dynamic memory, leaving 338 bytes for local variables. Maximum is 2,048 bytes. Low memory available, stability problems may occur.I'm by no means a C/C++ guy (which I why I'm writing this tool ;) ) so I'll need help to fix this. I don't even know where to start looking, since there's the combination of NodeManager and the software signing in the sketch.
Any chance you could look at this, @user2684 and @Anticimex? You could download a copy of the code from the UI if you like. My configuration is an NRF network, and the gateway is the default serial gateway on the UI. I've been using the latest version of the MySensors lib from the development branch on GitHub, and am doing the compilation in the Arduino IDE.
Thanks!
@rakeshpai I have never used node manager myself but it appears that it consumes quite some memory. I have to my best effort optimized the signing code to use as little memory as possible. That said, it could very well be possible to optimize it further, but I would then need other eyes on it. I have not looked into node manager, but as I understand it, it relies heavily on c++ (signing code is pretty much just c) and the atmega compiler optimized c++ code horribly bad. So I think that it is in nodemanager the biggest memory savings can be made.
-
@rakeshpai I have never used node manager myself but it appears that it consumes quite some memory. I have to my best effort optimized the signing code to use as little memory as possible. That said, it could very well be possible to optimize it further, but I would then need other eyes on it. I have not looked into node manager, but as I understand it, it relies heavily on c++ (signing code is pretty much just c) and the atmega compiler optimized c++ code horribly bad. So I think that it is in nodemanager the biggest memory savings can be made.
-
@Anticimex That's the feeling I had as well, considering that even after I disabled signing, while the sketch fits in memory, it still seemed to complain about low memory. @user2684 does this match your experience too?
@rakeshpai the warning is because the heap and stack is shared. So as the program claims storage for variables (typically globals statics and classes) the ram available for stack shrinks. And at some point it becomes to small. But the tools cannot determine when that happens as such analysis is quite complex. So they warn when it "feels" to be getting tight. But it ultimately comes down to how the program behaves and how the code handles function calls and parameters. So if you get the warning, it does not mean there is a problem. But you have entered what somebody decided to be the "danger zone" (probably based on typical sketch stack usage).
-
@Anticimex That's the feeling I had as well, considering that even after I disabled signing, while the sketch fits in memory, it still seemed to complain about low memory. @user2684 does this match your experience too?
@rakeshpai sorry for the delay! NodeManager consumes some good memory indeed but I should have optimized this in v1.5 and the problem should have gone unless a lot of sensors are registered but this is not your case. Are you already using this version?
As a side note, I've noticed when MY_RF24_ENABLE_ENCRYPTION is defined a good 20% of memory got consumed on a pro mini but I guess this is not something we can do much about :) -
Correction, this has been solved only in the development version :-( (https://forum.mysensors.org/topic/6183/nodemanager-plugin-for-a-rapid-development-of-battery-powered-sensors/168).
But I'd recommend not to move there because a few things have changed and I'd prefer to provide you with a better recap of the changes to make your life easier. Probably best is that I put together a v1.5.1 version with just that issue fixed for you to use. I'll work on it and let you know between today and tomorrow. Thanks! -
Generally, the beta branch of the MySensors library has much "better" memory footprint than the current release. This is also true for signing.
-
Correction, this has been solved only in the development version :-( (https://forum.mysensors.org/topic/6183/nodemanager-plugin-for-a-rapid-development-of-battery-powered-sensors/168).
But I'd recommend not to move there because a few things have changed and I'd prefer to provide you with a better recap of the changes to make your life easier. Probably best is that I put together a v1.5.1 version with just that issue fixed for you to use. I'll work on it and let you know between today and tomorrow. Thanks!@user2684 My version management is pretty crappy at the moment ;) but I'm simply using the latest version of NodeManager.cpp and NodeManager.h from the master branch on GitHub. Users keep a local copy of NodeManager for purposes of offline availability, but they are forced to update their local versions of NodeManager everyday. So, it's safe to assume that within a margin of error of a day, everyone's on the latest version of your checkins on GitHub. (I know this isn't ideal and I should do version management better, but I too like to live dangerously B).)
Also, while MySensors itself isn't shipped as part of the download bundle, I've manually used the latest version from the dev branch in GitHub as well, in my arduino libraries folder.
Maybe I'm just doing something stupid that's causing the memory usage to inflate? I'll wait for whenever you can get a chance to review the output code. Thanks for looking at this!
-
@user2684 My version management is pretty crappy at the moment ;) but I'm simply using the latest version of NodeManager.cpp and NodeManager.h from the master branch on GitHub. Users keep a local copy of NodeManager for purposes of offline availability, but they are forced to update their local versions of NodeManager everyday. So, it's safe to assume that within a margin of error of a day, everyone's on the latest version of your checkins on GitHub. (I know this isn't ideal and I should do version management better, but I too like to live dangerously B).)
Also, while MySensors itself isn't shipped as part of the download bundle, I've manually used the latest version from the dev branch in GitHub as well, in my arduino libraries folder.
Maybe I'm just doing something stupid that's causing the memory usage to inflate? I'll wait for whenever you can get a chance to review the output code. Thanks for looking at this!
@rakeshpai great so yes, you are using the latest version and btw, very smart method for keeping it up to date ;-) No, you are not doing anything stupid, it was me doing something stupid when releasing the latest version of NodeManager :-) Of course together with encryption enabled this would end up consuming almost all the memory but the original sin was on my side. I'll definitely work on a hotfix for you, otherwise the code would become useless. And of course I'll review the output code but apologize in advance, real life will be very demanding for me in the next few months so my response will be almost always delayed :-(
-
@rakeshpai great so yes, you are using the latest version and btw, very smart method for keeping it up to date ;-) No, you are not doing anything stupid, it was me doing something stupid when releasing the latest version of NodeManager :-) Of course together with encryption enabled this would end up consuming almost all the memory but the original sin was on my side. I'll definitely work on a hotfix for you, otherwise the code would become useless. And of course I'll review the output code but apologize in advance, real life will be very demanding for me in the next few months so my response will be almost always delayed :-(
-
@user2684 No problem with the delays - I've got enough things to do in the meantime. All those real-life things coming in the way all the time, amirite? :)
@rakeshpai yes indeed :-)
I wonder if you can give a try to https://github.com/user2684/NodeManager/tree/release/1.5.1 before I'll make publicly available. It is basically the same v1.5 version you are using which just applied the memory optimization patch on top. It should save 25% of the memory so it is a huge fix :-)
Let me know if works better. Something else I recommend to disable when you are approaching the memory limit is#define DEBUG 1which will prevent storing all the debug messages giving you another boost.
Generally speaking you need to stay pretty distant from the 100% memory utilization with NodeManager: since it is allocating its objects dynamically (which is not a good practice but I couldn't find a better way), you can get weird behavior even if the compiler doesn't not complain.Thanks!
-
@rakeshpai yes indeed :-)
I wonder if you can give a try to https://github.com/user2684/NodeManager/tree/release/1.5.1 before I'll make publicly available. It is basically the same v1.5 version you are using which just applied the memory optimization patch on top. It should save 25% of the memory so it is a huge fix :-)
Let me know if works better. Something else I recommend to disable when you are approaching the memory limit is#define DEBUG 1which will prevent storing all the debug messages giving you another boost.
Generally speaking you need to stay pretty distant from the 100% memory utilization with NodeManager: since it is allocating its objects dynamically (which is not a good practice but I couldn't find a better way), you can get weird behavior even if the compiler doesn't not complain.Thanks!
@user2684 Tried with the 1.5.1 release, and it fits!
Sketch uses 25,786 bytes (83%) of program storage space. Maximum is 30,720 bytes. Global variables use 1,716 bytes (83%) of dynamic memory, leaving 332 bytes for local variables. Maximum is 2,048 bytes. Low memory available, stability problems may occur.It's still complaining about low memory, and from what I understand of what you said, this is a problem, but this is definitely an awesome direction. It's also a concern that I still haven't added any sensors yet - this is just a bare serial gateway sketch. However, I'm still excited. :metal:
I've kept debug off by default in the config for now, so debug messages aren't pushing us to the limit here.
EDIT: I must add, the result above is with signing and encryption, and all that good stuff.
-
@user2684 Tried with the 1.5.1 release, and it fits!
Sketch uses 25,786 bytes (83%) of program storage space. Maximum is 30,720 bytes. Global variables use 1,716 bytes (83%) of dynamic memory, leaving 332 bytes for local variables. Maximum is 2,048 bytes. Low memory available, stability problems may occur.It's still complaining about low memory, and from what I understand of what you said, this is a problem, but this is definitely an awesome direction. It's also a concern that I still haven't added any sensors yet - this is just a bare serial gateway sketch. However, I'm still excited. :metal:
I've kept debug off by default in the config for now, so debug messages aren't pushing us to the limit here.
EDIT: I must add, the result above is with signing and encryption, and all that good stuff.
@rakeshpai looks good. I get that warning myself and I have only seen issues when I push 90% but it also depend on what your sketch does. In any case, the warning is no guarantee for failure so I think it can be considered acceptable in most situations.
-
Output from the gateway's serial:
NodeManager v1.5.1 INT1 M=255 INT2 M=255 0;255;3;0;14;Gateway startup complete. 0;255;0;0;18;2.2.0-beta RADIO OK 0;255;3;0;11;Gateway 0;255;3;0;12;1.0 PRES I=200, T=23 0;200;0;0;23; READY MY I=0 M=1 SEND D=0 I=200 C=0 T=48 S=STARTED I=0 F=0.00 0;200;1;0;48;STARTEDOutput from a dummy node's serial:
REG I=1 P=14 P=16 T=23 PWR G=0 REG I=1 P=14 P=16 T=23 PWR G=0 V=12 NodeManager v1.5.1 INT1 M=255 INT2 M=255Ok, so the both aren't talking to each other yet, and I'll investigate that. BUT! This is NodeManager 1.5.1 + Signing + Encryption, flashed on to two Arduino Pro Minis 3.3v, one with a serial gateway sketch, and the other with the node for a simple sketch of a LDR sensor, both generated from the UI!
You can't see me here, but I'm doing a little dance! :P
While I complete my little dance here, if you can spot anything obvious about why they aren't talking to each other, please let me know.
Also, minor UI update: New 'Are you sure?' dialogs when you are performing any deletions on the UI.
-
Output from the gateway's serial:
NodeManager v1.5.1 INT1 M=255 INT2 M=255 0;255;3;0;14;Gateway startup complete. 0;255;0;0;18;2.2.0-beta RADIO OK 0;255;3;0;11;Gateway 0;255;3;0;12;1.0 PRES I=200, T=23 0;200;0;0;23; READY MY I=0 M=1 SEND D=0 I=200 C=0 T=48 S=STARTED I=0 F=0.00 0;200;1;0;48;STARTEDOutput from a dummy node's serial:
REG I=1 P=14 P=16 T=23 PWR G=0 REG I=1 P=14 P=16 T=23 PWR G=0 V=12 NodeManager v1.5.1 INT1 M=255 INT2 M=255Ok, so the both aren't talking to each other yet, and I'll investigate that. BUT! This is NodeManager 1.5.1 + Signing + Encryption, flashed on to two Arduino Pro Minis 3.3v, one with a serial gateway sketch, and the other with the node for a simple sketch of a LDR sensor, both generated from the UI!
You can't see me here, but I'm doing a little dance! :P
While I complete my little dance here, if you can spot anything obvious about why they aren't talking to each other, please let me know.
Also, minor UI update: New 'Are you sure?' dialogs when you are performing any deletions on the UI.
@rakeshpai The first question that comes to mind is, have you double checked your AES personalization? If you run with encryption enabled and have a mismatch in the PSK then nothing comes through in any direciton.
You can execute the personalizer without flags set and it should dump the EEPROM data on serial.