OK so you import your devices library, write BOARD.py, modify the makefile and build_linker.py, and then implement jshardware.c / main.c. Finally you get it to compile for your board and it doesn't work at all. What now? How do you recommend troubleshooting/debugging espruino? What are some small steps I can break debugging into? (All im trying to do at this point is get my board talking to Espruino's web ide).
How you debug is going to depend on your board and processor. Ideally you'd have some kind of SWD/JTAG debugger that could could attach and use to step through your code, to check it's initialising properly.
Failing that, make main.c simply print 'Hello world' or something out of the serial port (without initialising Espruino at all). Then make sure you can get serial receive working (so it'll echo back the result) and work forwards from there - adding loads of print statements, trying to initialise Espruino and finally start looping and calling jsiIdle.
If you do need help it's possible I could do some consultancy work for you though.
OK, my problem has been that after I compile system startup seems to work fine. It call SystemInit and this returns. Then it calls _start and the program crashes there before ever reaching main? Any clues about what could be going wrong here?
If I keep CFLAGS, LDFLAGS, ARCHFLAGS etc... the same as you have it works but once I start using flags from Nordics example makefiles the code breaks. but ive been wondering if the way im compiling/linking is causing this.
To be honest it could be anything - it's not really an Espruino problem at all. It might help to figure out exactly how it's crashing. I'd step through _start instruction by instruction and figure out where it dies.
All I can think right now is that _start - which I guess is provided by Nordic - expects some variables to exist that might have been defined in linker.ld. Espruino's version of the linker file might not define the correct ones, or might use different names.
OK, found the problem. Some makefile/linkerscript problems. Got the bare bones working today though! Able to blink an LED from the chrome ide :)
Wow, that's great! When you're happy with it, could you push your changes back on GitHub? It's be great to have a bit more platform support.
If you're looking at adding BLE support at some point, it might be worth doing something similar to bleat - as that seems to be a relatively standard JS API now.
I would like to port it to STM32F405, should be an easy task but there is too many place with #define ... will try compiling as a PICO and change only linker file and mem.
Yes, F405 should be pretty easy. No need to change the linker file as it's generated automatically from the details (RAM/Flash) in the BOARD.py file though.
Going to make a pull request today. Also working on BLE support now but should have more details in pull request. Thanks for all the help so far!
Great, thanks! I look forward to it :)
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem