Custom native firmware? #3636
Replies: 6 comments
-
Posted at 2021-01-27 by AkosLukacs First, you can compile javascript to C: https://www.espruino.com/Compilation That might help. Or haven't seen what is exactly slow, but there might be room for some optimization. If you have some functionality that is not supported by the espruino Js -> C compiler, you can add your own C code: https://github.com/espruino/Espruino/blob/master/libs/README.md If you want to do 100% custom code, Nordic semi's website is your best bet I guess: https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52832 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-27 by @fanoush between first and second choice there is also https://www.espruino.com/InlineC |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-27 by DanTheMan827 I'd rather just write the code in native C instead of dealing with anything the JS to C transpiler might introduce. I don't have an issue with C code, I'm just a little confused with how the compile process works, especially when you consider that the puck.js has secure dfu My code when you really boil it down can be condensed into a single switch statement on the first byte of the received data since all NFC commands are one byte |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-27 by @fanoush So you don't need bluetooth either? what you do with bytes received over nfc then? Anyway, you can start with |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-27 by DanTheMan827 I don't actually need bluetooth at this very moment, what I'm doing is writing a NTAG215 tag emulator that has a couple different slots that can be swapped with the button that also has a backdoor NFC command that allows rewriting the entire "tag". I might add in bluetooth later so that I can just manage the tag data directly from an app, but I don't even have that implemented in javascript yet. After looking into inline c, that could potentially be all I need, but I am curious if I could call the NRF.nfcSend() directly from the C code in some way, that would certainly simplify and speed up things in that respect by not having to pass the response data back to the javascript side of things. it's not that I dislike the javascript environment, it's just not fast enough it seems to process and send the ntag215 response back within the few ms required. As far as debugging, I have pin headers on my puck and just connect over uart. here's what I have so far, it does work, but not all devices are very accepting of the timings. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-28 by @gfwilliams Hi - the issue you might be having is (as you say) the delay introduced by Espruino's JS handling of NFC. Hopefully you could write some Inline C code, but Espruino still executes that code outside the interrupt in which it happens, which would introduce some lag. As others have said, the Puck is just a standard nRF52832 using SDK12. You could get Nordic's tools set up and then just start compiling and uploading their NFC examples and they should 'just work': https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.3.0%2Findex.html&cp=7_5_9 However you'll probably find that a very steep learning curve. We've had to patch Nordic's NFC libraries to let us get that low level with tag handling. So there is a bit of a middle ground - just compile the Espruino firmware and make some tweaks to it. If you've some knowledge of Linux it should be totally trivial: https://github.com/espruino/Espruino/blob/master/README_Building.md#under-linux Then you can add your code into the NFC handler here: https://github.com/espruino/Espruino/blob/master/targets/nrf5x/bluetooth.c#L1525 At that point (nfc_callback) you're running in an IRQ, so anything you do should be extremely fast. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-01-27 by DanTheMan827
So I found out that javascript isn't quite performant enough for my project and I want to jump off the deep end and write my code in native C, but for programming micro controllers I've only ever used the Arduino IDE.
Is there any sort of blink example project already configured with a Makefile that builds a DFU image for the Puck.js?
I don't really have a need for the additional sensors that the puck includes, I only have a need for NFC related functions at the moment.
I'm no stranger to Linux either.
Beta Was this translation helpful? Give feedback.
All reactions