Getting the emulated USB serial port (CDC-ACM) to work on the nrf52840

Hello, I hope this is the right forum for this question. I am currently working on a nrf52840 based board (to be more exact its based on the ublox bmd-341 module) we have flashed the open_bootloader_usb_mbr_pca10059_debug.hex contained in the nrf dev-sdk on it with the help of our ST-Link/V2 and openocd, we thought, that since it has the functionality we want (mainly being able to upload programs over usb and a known flash process on the RIOT Wiki) it would be a good point to start. After flashing I was able to upload programs with the help of either nrfutil or the programmer that comes with nrf connect for desktop. The thing is I have tried for hours and I can’t get serial out, it seems to connect to it no problem but I don’t get anything out of it. I don’t even know if my settings asside from picking the right device and com port are the right ones (but usually with serial if the settings aren’t right you still get something even if its just a garbled up mess right?)

My process currently looks like this: In WSL I enter the folder /examples/hello-world, I tehn execute the command:

make BOARD=nrf52840dongle

Since I just wasn’t able to set up the connection of my board in WSL I then take the hello-world.hex out of the hello-world\bin\nrf52840dongle\ folder and bring it to my windows host system. There I use the commands

nrfutil pkg generate --hw-version 52 --sd-req=0x00  --application hello-world.hex --application-version 1 app.zip
nrfutil device program --firmware app.zip --traits nordicDfu

to flash it to the nrf52840. It goes through with no issues.

Since I don’t have a Segger J-Link, which seems to be required for almost all debugging, I don’t even know how I should start debugging this issue, I hoped I could get atleast the serial to work.

My programm has been a fearly simple modification of the hello_world example of RIOT-OS.

#include <stdio.h>

int main(void)
{
    while(1){
   	 puts("Hello World!");

   	 printf("You are running RIOT on a(n) %s board.\n", RIOT_BOARD);
   	 printf("This board features a(n) %s CPU.\n", RIOT_CPU);
	}
    return 0;
}

The makefile looks like this:

# name of your application
APPLICATION = hello-world

# If no BOARD is found in the environment, use this default:
BOARD ?= native

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
DEVELHELP ?= 1

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

USEMODULE += stdio_cdc_acm

include $(RIOTBASE)/Makefile.include

Hoping for quick help since I am approaching a deadline and I already poured way too much time into it while basically just fishing in the dark :sweat_smile:

Can you blink an LED - that is, are you sure RIOT is actually running? Since you have a bootloader, did you set ROM_OFFSET?

If you flashed the bootloader using ST-Link, you should also be able to use it for debugging - or better yet, just flash RIOT with it (no bootloader): make PROGRAMMER=openocd OPENOCD_DEBUG_ADAPTER=stlink flash

Sorry that I didn’t answer, I read you comment as you sent it but I was way to busy with submitting the project ^^’ We sadly have no functioning LED since something unexpected went wrong in our manufacturing process. I had to give up since the hardware side of things had to be submitted already. But still I appreciate that you tried to help. The only thing stood out to me is the ROM_OFFSET, is that a RIOT option or where would I set that? Maybe I can give my Professor some tips as to what could be done after the project is finished, since he also seemed very eager to get it to work.

You can set it in the Makefile. But if you have a programmer (ST-Link) you don’t necessarily need the bootloader, you can directly flash your app with it - then you don’t need to set any offset.