Puck.js Crashes w/ Custom Firmware #3758
Replies: 5 comments
-
Posted at 2021-06-29 by Cryptizard Fixed it by adding mbedtls_ecp_group_init before the line that was crashing. Not sure why this is necessary since the first line of the load function immediately frees the group, and it worked fine in Linux the way it was originally written, but it works now on the puck. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-06-29 by @fanoush you cannot use malloc, there is no dynamic memory in nrf52 build. just allocate static buffers however there is jsvMalloc https://github.com/espruino/Espruino/blob/ffe45409c90f22b42a9369489cbbc1f85d9b02ce/src/jsvar.c#L4210 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-06-29 by Cryptizard Weird, I am using malloc in several places and it works fine now after I fixed the init thing, so that note can't be correct. I will change it to static buffers just to be safe. Thanks for the help! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-06-30 by @fanoush whole 64KB of RAM is allocated to nordic softdevice for bluetooth then static variables including big static array of js variables (as per value in board file) and then cpu stack. Can you print addresses that malloc gives you? maybe it grows from the bottom of cpu stack so few bytes will not corrupt it |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-06-30 by @gfwilliams Yeah, using For That's the main difference between PC and embedded (apart from total stack size) so I'd say it's good thing to look into. If you look at other Espruino functions we tend to use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-06-29 by Cryptizard
I have built a new firmware for the Puck.js in order to add a C function that does some Elliptic Curve math that would be too slow in JS. I have gotten this firmware to build and load onto the puck successfully, but when I try to run the function I wrote it crashes for some reason (puck becomes unresponsive, disconnects from Web IDE). The function is included below for reference. I used LED lighting to narrow down where exactly it stops working and it appears to be on the line with "mbedtls_ecp_group_load".
When I build Espruino with a LINUX target, this code works completely fine, so there doesn't appear to be anything wrong with the code itself. I'm having trouble debugging what could be wrong here. Is there any way to attach a debugger to the Puck or something else I could do here? It seems very difficult to debug C code on the Puck because if anything goes wrong it just disconnects from the Web IDE.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions