-
-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugging: can't get LMIC_PRINTF_TO working on SAMD21 #270
Comments
Hmm, I have no problems compiling the ttn-otaa example for the Arduino Zero with
Are you using the latest version (1.5.0+arduino3)? It was recently fixed to support non-AVR printf as well (though your error suggests you already have the fix, or maybe you're usign the old non-avr-printf (or something like that) branch? Note that the IDE library manager seems to mis-sort the versions and tends to install an older version. What board and core are you using exactly? This is printed by the IDE on (verbose) compilation as I pasted above. (as for the underlying issue - I have no suggestions from the top of my head, other than indeed enabling debug output :-p) |
The board that I'm using is the "SenseBox MCU" from SenseBox , with this board support package. Yes, I'm using LMIC version 1.5.0+arduino3. There is an older LMIC library included with the SenseBox packages, so I emptied that directory and copied the files for 1.5.0+arduino3 to that location. Probably not the cleanest approach, but (also looking at the verbose output) I'm 100% sure that it picks up the latest LMIC code this way. Could it be that the BSP needs some kind of patch/update to make this work? (as for the underlying issue: I've never seen this before, neither with AVR nor with ESP32 platforms. However, a faculty member who is involved in this project e-mailed me that he also observed this issue on ESP32+RFM95 several times. Anecdotical, but I would like to investigate further). |
Using core 'arduino' from platform in folder: C:\Users\ingenj\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.5
|
No time to reproduce right now, but looking at the install instructions for this board, it looks like it just uses the default Aduino SAMD core with some added boards in its I think these printf cookie functions are supplied by gcc/libc, so that should just work. I do notice that I have an older Arduino SAMD version (1.6.17, whereas you're using 1.8.5). I'll try upgrading later, to see if that works (or you could try downgrading just the Arduino SAMD core, see if that fixes it)? |
That's a good pointer, thanks! Yes, it does compile correctly when I downgrade Arduino SAMD support to 1.6.17. Will try to bisect where the breakage is introduced. In the mean time I compiled with the 1.6.17 so I can run a node with extensive debugging. |
Nice, thanks for testing. I can imagine two underlying causes then:
I'll explain the latter a bit more. In the Lines 11 to 17 in 54bc51d
We include To test this, you could try moving these three lines to above the Lines 15 to 17 in 54bc51d
That should ensure that |
Great! I'll try that in a bit. First update: without any other code changes, Arduino SAMD version 1.6.21 (last 1.6) works fine too; 1.8.3 and 1.8.5 don't. However, with your proposed fix, 1.8.5 works fine. So sounds like a good solution! And from the debug output to narrow down the TX issues: everything is OK when "Packet queued" is followed by "irq: dio: 0x0 flags: 0x8", whereas the cases where "Packet queued" is never followed by a "EV_TXCOMPLETE" event (and instead my workaround code has to kick in) are missing that irq. OK:
Not OK:
|
Sounds like somehow the IRQ is never fired (not that there is no actually interrupt line involved, the code just polls the DIO "interrupt" lines using |
The code is still calling |
With debugging enabled, LMIC wouldn't compile on SAMD targets when used with Arduino core greater than 1.6.21 (eg 1.8.x versions). Changing the order of includes fixes this. Suggested by matthijskooiman in upstream matthijskooijman#270.
@matthijskooijman I committed your suggested change in my fork (JeroenvIS@42f4eb0); it compiles cleanly both with and without So I think this is a perfect fix and can be merged or otherwise adopted in your branch. When that's done, I'll urge Sensebox to update the version that they are shipping with their package. |
FWIW: this was indeed the issue, introducing a certain probability that EV_TXCOMPLETE didn't come after queueing a packet. If I remove this line from the loop, LMIC Can't explain from a hardware and/or timing perspective yet, but I guess that's not too relevant for this PR anyway. |
This fix worked! I had to add these When will this fix being merged into https://github.com/mcci-catena/arduino-lmic ? EDIT: Maybe never, since it is not a wanted fix: mcci-catena#549 |
Base question/issue: I can't get LMIC_PRINTF_TO working on SAMD21. Tried with Arduino 1.8.6 and 1.8.12 on Windows, both with current LMIC. When I uncomment
#define LMIC_PRINTF_TO Serial
and set LMIC_DEBUG_LEVEL to 2, compilation of the sketch fails with the errorerror: 'cookie_io_functions_t' does not name a type
I'm lost how to fix this, it's way more low-level than I'm used to. Any pointers?
Background / reason for the debug: I'm running into an issue with the "Sensebox MCU", which is a SAMD21 based board. Node can join TTN successfully (OTAA) and usually transmits a couple of packets just fine (eg with a TX_INTERVAL of 60 seconds, rescheduling the os_job 60 secs after TX_COMPLETE as in common examples).
However, after a while, I don't see any data being received at TTN. The loop() is still running (observed by blinking LED) and with serial debug output for the sketch itself, I can see that the send_job has prepared the data just fine and emitted the "Packet queued" message. I never see a TX_COMPLETE event though. If I add some code to reschedule the os_send job if no TX_COMPLETE has been seen withing 15 secs after queueing the packet (only after join of course), it appears that
LMIC.opmode & OP_TXRXPEND
yields true.I haven't had issues like these on AVR, but I see this pattern on 4 out of 5 Sensebox MCU platforms and I believe that a working LMIC_PRINTF_TO might help me dig deeper.
The text was updated successfully, but these errors were encountered: