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
print ubxlib output to usb on nrf52840 dongle using Zephyr #215
Comments
Hi, and thanks for posting. So that I have some context, you say that you are using the nrf52840 dongle: I guess this means that you are compiling Zephyr for nRF52840, running the compiled Zephyr code on that nrf52840 dongle, and when you say "the com-port that is enabled by the usb-cdc-acm-console seems to be lost" that you were receiving debug output from Zephyr at a PC or some such over a USB-serial interface and that, once you added the "ubxlib" and "Need the following for U-Blox as well"
Since you are not running any |
Hi @RobMeades, Thank you for your prompt reply! I've started from a clean console printing 'hello world' example project. -> compiles and runs I'm including the library in CmakeLists.txt with
-printk output to be exact.
-Seems like it, yes. The only code I have in main is this. When setting CONFIG_UBXLIB=y
So I also enabled the following from the default.conf.
This does compile but then the com-port does not pop up when the code is flashed to the nRF52840. Am I understanding correctly that the conf of default.conf is used for compiling when I include it in CmakeLists? During compiling I see the following message. Thanks in advance for your help! |
I don't use Zephyr on a day to day basis myself, so I also find it very difficult to follow; it is extremely complicated because it is trying to support pretty much everything there is and remain small and remain flexible; an impossible task without accidentally appending "and extremely complicated" on the end :-(.
The line Adding
Those lines enable
Yes, just adding
If you look at the detail of the |
Just to add, I don't see how any of the above could relate to an nRF52 dongle's USB interface suddenly not working. You say "then the com-port does not pop up". Not "popping up" I guess means that the USB interface is not enumerating. I was going to say that this sounds like the nRF52 is not booting but the nRF52 doesn't have a USB interface, there must be some other chip on the dongle which provides that interface, and that must be booting, otherwise you would not be able to re-program the nRF52. Why would the USB interface chip suddenly not enumerate its output? All I can suggest is backing-out changes until things work, so that you can pin-point what is going wrong. Can you confirm that the |
Hi @RobMeades, Thanks for helping! This is my CmakeLists.txt.
Adding ubxlib to ZEPHYR_EXTRA_MODULES is working.
This is when I include the lines for ubxlib in CmakeLists.txt and include the ubxlib lines in proj.conf. When I remove the ubxlib lines in proj.conf, the com-port opens and serial data is being written to my terminal. For completeness, I'm using this dongle. |
Where is the picture you show above from? I agree that it shows the From what you say I understand that the USB com port over which debug arrives is enumerating but nothing is being sent over it, which takes us back to the possibility that, for whatever reason the nRF52 is not booting. Is there any other way you could tell whether the nRF52 was booting? For instance, could you light an LED or some such so that you could determine if it has entered your main application? With no debug output, LED's are the thing I'm afraid, we've all been there :-). As indicated above, since you are using no Lines 7 to 8 in 1b94ec5
Not that it should make any difference but, FYI, you have:
...but including the |
To be clear, we build/run our regression tests on nRF52840 constantly, so there is nothing fundamentally wrong here, which is what makes it all the more strange. |
I understand from one of my colleagues that this board in fact uses a USB block inside the nRF52 itself, for which driver code needs to be included etc., which I am sure the sample you are using is doing. He's going to see if he can dig up one of these boards himself to see what happens (he will dive in here with any input when he does). I don't know how long that might take though so I would encourage you to (a) get an LED on the board (assuming it has one) operating so that you can flash it in the working case and then (b) flash that LED at entry to your application in the non-working case to see if the code is getting that far. |
@RobMeades, I will check with some LED sample code to see if the application starts. @plerup, my journey started at this post. I'm using the one from Zephyr. The only difference from the Zephyr example is that they also include a usbd_next.
-Yes they seem to be included when building.
-When I do that, the "Hello World! arm" message is printed. Here I have included ubxlib in the CmakeLists.txt. Then it does not show in the build logs or in the build source files in vscode (like the image included before). |
Agreed, your
Not sure I'm following this: could you maybe rephrase? Are you saying that, in the success case, so with the "Hello World! arm" message being printed, you are including |
The succes case: (printing to the terminal over USB) The non-succes case: (not printing to the terminal over USB) I"m including
-Well, I'm including ubxlib in the
|
Thanks for the clarification. The line:
...should have the effect of bringing in all of the Can you try just defining |
Sorry, I see you did this originally and that caused the compilation error:
I don't understand any of this, let me try doing exactly what you are doing myself; I don't have one of those boards but I can try to see why the right definitions aren't getting to the right places. |
I've included a GPIO led in my main. It is blinking when I do not include ubxlib in the I've added my code in the zip below. |
Got it, so one or more of the |
From a blank environment, to reproduce your build locally, I have done the following:
[The command on the end to show the verbose build output]. This built to completion, output from Attached find the zephyr.elf file it built (renamed to |
Hi @RobMeades, Strange that it does want to compile just with |
Yes, I can't explain any of this; zephyr.hex attached, renamed with What version of nRFConnect are you using? We test with 2.5.0, which contains Zephyr 3.4.99, but we also test with native Zephyr (i.e. outside nRFConnect) 3.6.0 as well, so there's plenty of coverage here. |
Checking the end of your
I get:
Now I would expect the RAM to be quite different, as you are only defining a small heap, but the flash size is half in your build versus mine, and we're using the same optimisation settings etc. as far as I know...? |
Hi @RobMeades, That worked! It's printing 'Hello World! arm'. I'm using nrfConnect v2.5.2 I'm using the project's default optimization. This is mentioned in the |
Well, I suppose that is kind of good news; I am using the default settings in this "console" example, so should all be the same as yours. Let me go grab nRFConnect 2.5.2 and see if that is any different. |
I have now repeated the procedure, only difference being that I have pointed the build at the version of Zephyr that comes with nRFConnect version 2.5.2:
...and I have freshly copied One thing to think about is, is there enough heap? You have set it 20ish kbytes: is it clear that is sufficient for whatever the build is doing? You might try a bigger number. It is also strange that your build output complains that both "Debug" and |
Succes! I uninstalled everything and installed the toolchain through the nrf extension pack in VScode. The code compiles and runs now. Thank you so much for your help! However..I am now getting a -5 error when opening the device.
Do you know what it could be? |
Excellent! If |
I currently have the following:
sda and scl pins are defined in |
Thanks, a few comments/questions:
Otherwise the structure looks fine. During device open the |
I see, thank you for the support. This is my current overlay (maybe it's usefull for other people in the future):
u_cfg_app_platform_specific.h
This is what I get printend in the terminal:
I did expect the callback to print out the position. Is that correct?
EDIT:: |
From a quick check that code looks OK. You are calling uGnssPosGetStreamedStart() and, I guess, giving it your As explained above the function signature for uGnssPosGetStreamedStart(): Lines 245 to 259 in 1b94ec5
...you will get a timeout error if the GNSS device has not been able to establish position. While doing streamed position we switch off printing-out of the messages arriving from the GNSS device as they would get in the way but, if you wish to see them temporarily to confirm that they really are arriving, after your call to uGnssPosGetStreamedStart() you could call uGnssSetUbxMessagePrint(devHandle, true) to switch message printing back on again. |
Hi @alehanderoo: were you able to get a GNSS fix in the end? |
Hi there,
I have a nrf52840 dongle and I'm using the usb console example to print something to the terminal. ->This works fine.
When I import ubxlib to my project as explained here it compiles and flashes, but the com-port that is enabled by the usb-cdc-acm-console seems to be lost.
Does ubxlib require a specific hardware block to write the output on?
I'm fairly new to Zephyr and ubxlib, so any help/improvements would be highly appreciated.
app.overlay:
`
/ {
chosen {
zephyr,console = &cdc_acm_uart0;
};
};
&zephyr_udc0 {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};
&i2c0 {
compatible = "nordic,nrf-twim";
status = "okay";
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
mysensor: mysensor@42{
compatible = "i2c-device";
reg = < 0x42 >;
label = "MYSENSOR";
};
};
&pinctrl {
i2c0_default: i2c0_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 31)>,
<NRF_PSEL(TWIM_SCL, 0, 29)>;
};
};
i2c0_sleep: i2c0_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 31)>,
<NRF_PSEL(TWIM_SCL, 0, 29)>;
low-power-enable;
};
};
};`
prj.conf:
`CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr USB console sample"
CONFIG_USB_DEVICE_PID=0x0004
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_LINE_CTRL=y
CONFIG_GPIO=y
CONFIG_I2C=y
CONFIG_GNSS=y
CONFIG_GNSS_SATELLITES=y
CONFIG_GNSS_NMEA0183=y
CONFIG_UBXLIB=y
CONFIG_UBXLIB_GNSS=y
CONFIG_DEBUG=y
CONFIG_ASSERT=y
CONFIG_INIT_STACKS=y
CONFIG_THREAD_STACK_INFO=y
CONFIG_THREAD_NAME=y
CONFIG_KERNEL_MEM_POOL=y
CONFIG_HEAP_MEM_POOL_SIZE=20000
CONFIG_MINIMAL_LIBC_MALLOC=n`
The text was updated successfully, but these errors were encountered: