RAK8212: Issue with save() freezing up the system #7306
Replies: 1 comment
-
Posted at 2018-09-26 by @gfwilliams Are you connecting through Bluetooth, or USB Serial? Can you also maybe try removing the Posted at 2018-09-26 by wklenk Hi, I am connecting through Bluetooth. Then I started with a tiny module BG96NB1.js, adding more and more lines of code step by step. The largest size of the overall program I could see was 12261 (0x2FE5) bytes.
This makes me assume that there must be some kind of limit at about 12288 (0x3000) bytes.
Found this in https://github.com/espruino/Espruino/blob/master/boards/RAK8212.py :
Does this mean 3 * 4096 byte only for saved code? Posted at 2018-09-27 by @allObjects I glanced over the module code... and even though I agree with the approach of using Promises to get over the asynchronous needs, you might resort to something much less elegant... One of the main reasons is that Espruino runs off of the source code. The interpreter has to have a reasonable expression in JS to get to work. The highly elegant and correct solution with so many Promises in one single expression could render just to much for Espruino to deal with. I may be completely wrong, but I would use a simple sequencer / tasker / state machine to do that. I built something similar to overcome asynchronous calls in a sequence with retry support (yes, retry support can also be implemented in Promises, as I just very recently came across in the forum in order to break out/fail/reject after x timed retries, but again, it is within Promises and may pull in even more such):
I'm sure you try to save the code before even somethings started to run, correct? Posted at 2018-09-27 by wklenk
Thanks for the idea with the state machine. In fact, in the end the code has to run unsupervised and therefore it has to be more robust and resilient. The idea is to build a basic data logger that runs directly from flash when the device is powered on. The data should be sent using protocols like MQTT, CoAP or HTTP. Posted at 2018-09-27 by @allObjects Regarding robustness: are you considering setTimeout()/setInterval() of monitor tasks that worst case hit the reset button if something got hanging? ...or even more independent, like an extra watchdog mc - simple 8 bit STM8 or alike that would monitor? ...and they would monitor each other? Posted at 2018-09-27 by @gfwilliams Thanks for looking into this - you're right. I'm not sure how the RAK boards ended up with only 12k reserved for saved code. I've just updated this to 40k like the other nRF52 devices. There is some compression support in Espruino so 12k isn't as dire as you might think, but it's still easy to hit (although hopefully when you're using a built-in module for BG96 that'd reduce your code size even further). The fact that it actually crashes when trying to save too much is bad news though. I'll take a look at that - it should just report that the saved code is too big. Posted at 2018-09-27 by @gfwilliams Ok, just checked up on this - turns out it's a bug in the Storage code that makes it crash if you try and write a bigger file than will fit in memory (but only when Storage is empty!). It's now fixed, so cutting-edge builds should be working fine. Posted at 2018-09-27 by wklenk Hello Gordon, these are really good news :) bootloader_espruino_1v99_RAK8212.hex But shouldn't there be another hex file that contains the complete Espruino firmware? Best regards, Posted at 2018-09-28 by @gfwilliams Argh - sorry. I made some code changes late yesterday and forgot to add a few new files. If you wait a few seconds it should be fixed now. Posted at 2018-09-28 by Kartman Gordon, I had hoped you'd pick up on the problem! It now builds for me. Posted at 2018-09-28 by wklenk Great! Thanks a lot for all the support. Posted at 2019-04-04 by user97438 I also met the same problem by using the latest espruino_2v01_RAK8212.hex (3 April,2019), could you please share with me how to solve it? Posted at 2019-04-04 by Kartman I didn't solve it! Gordon did. Posted at 2019-04-05 by user97438 Hi Gordon, can you please tell us how to solve it? Posted at 2019-04-06 by user97438 anyone can help ? Posted at 2019-04-08 by @gfwilliams You mean 'save()' is hanging for you? It's possible it's the code you uploaded. Can you try a 'cutting edge' build, just in case? http://www.espruino.com/Download#RAK8212 Posted at 2019-04-08 by user97438 not hanging when doing " save", it's hanging when new restarting. Posted at 2019-04-08 by @gfwilliams It might just mean that you uploaded code that caused it to hang? Can you get it working by shorting TILT_DOUT to 3.3v and restarting? That'll make it not load any saved code on boot. If that works then try uploading and saving some really simple code (like turning an output on and off) and see if that works. Posted at 2019-04-08 by user97438 it worked when we used the really simple code, when we tested by using https://github.com/wklenk/rak8212-espruino-nb-iot/blob/master/upload-ssl-certs-to-bg96.js. it can work after modifying a little for Singapore Cat-M1. even worked fine after doing "save", but it hanged when we restarted the board by turning off and turn on power Posted at 2019-04-08 by user97438 after re-flashing your latest 'cutting edge' build( 8/4/2019), it seems be improved, but still not reliable. sometime it hanged, sometime the codes lost . the board can't be restarted by shorting TILT_DOUT to 3.3v , also it can't be restarted by shorting P21RESET to 3.3v or GND. Posted at 2019-04-08 by user97438 it can be restarted by P21RESET to GND. Posted at 2019-04-08 by @gfwilliams
That's intentional - you need to restart while shorting TILT_DOUT to 3.3v to boot without loading code.
Ok, so there's some issue with your code by the sound of it. I'd suggest:
Posted at 2019-04-08 by user97438 there is no any error when doing "Load",
Posted at 2019-04-08 by user97438 after cold reboot , we can't see any error message most of time, sometimes we can see the messages as below "\r\nR" if we do "Load" this time , then everything worked fine. Posted at 2019-04-09 by @gfwilliams Is it possible that you're uploading the code, running Try uploading your code without any call to onInit and see if that helps. Or use Can you also try adding the code Also, looks like you may be using |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-25 by wklenk
I am currently playing around with a RAK8212 and wrote a module to interface with the Quectel BG96 that is aimed at Narrowband IoT (NB-IoT) communication. I tried my best, but I am a newbie and possibly the code quality is bad ...
But the actual issue is that when I call "save();" the RAK8212 freezes up and I need to press the reset button to get it back into live.
I would appreciate some hints what I am doing wrong or how the issue can be solved.
I have placed the code into a github repository at https://github.com/wklenk/rak8212-espruino-nb-iot
Output:
Beta Was this translation helpful? Give feedback.
All reactions