[upload] /dev/ttyACM0/firmware.hex: Not a directory

Hello,

I have been trying to test PlatformIO on Ubuntu 64 with an nRF52 DK using the mbed framework. I think I have installed all of the command line tools and the VSCode based IDE. All of which seem to work.

My test program is a simple blinky with the following main.cpp:

#include <mbed.h>

DigitalOut led1(P0_17);

// main() runs in its own thread in the OS
int main() {
while (true) {
led1 = !led1;
wait(0.1);
}
}

The platformio.ini looks like this:

[env:nrf52_dk]
platform = nordicnrf52
board = nrf52_dk
framework = mbed

Now I can successfully build a firmware.hex file and flash this to the nRF52 with nrfjprog using the following commands:

nrfjprog --family nRF52 -e
nrfjprog --family nRF52 --program firmware.hex
nrfjprog --family nRF52 -r

However if I use the Upload button in the IDE or the CLI command:

platformio run -t upload --upload-port /dev/ttyACM0/

I get the following error:

*** [upload] /dev/ttyACM0/firmware.hex: Not a directory
=============================================== [ERROR] Took 3.79 seconds ==

Please could you suggest how I might resolve this?

Does this board has mbed bootloader with Drag & Drop? Do you see media disk?
See also Communicate outside the container - Balena Documentation

Yes, the nRF52-DK appears as a media disk. You can flash the drive by copying the firmware.hex file to the folder. Does that interfere with the PlatformIO upload method?

Having the trailing / on the upload port looks wrong - /dev/ttyACM0 should be a dynamically created device node, not a directory. What do you get if you execute the following command in the shell:

ls -l /dev/ttyACM0

paul@laptop01:~/Projects/Embedded/MBed/PIONRF52Blinky$ ls -l /dev/ttyACM0
crw-rw----+ 1 root plugdev 166, 0 Dec 13 12:40 /dev/ttyACM0

I get the same error if I remove the trailing /, I don’t think that is part of the problem here?

What is the path of this disk?

Sorry for the slow response, I’ve been away from work for a few days. The nRF52-DK auto mounts on Ubuntu as:

/media/paul/JLINK/

Thanks.

Try platformio run -t upload --upload-port /media/paul/JLINK

When I try:

platformio run -t upload --upload-port /media/paul/JLINK

The build ends with this:

Checking program size
text data bss dec hex filename
8892 256 53256 62404 f3c4 .pioenvs/nrf52_dk/firmware.elf
Building .pioenvs/nrf52_dk/userfirmware.hex
Building .pioenvs/nrf52_dk/firmware.hex
Looking for upload disk…
Use manually specified: /media/paul/JLINK
Uploading .pioenvs/nrf52_dk/firmware.hex
*** [upload] /media/paul/JLINK/firmware.hex: No such file or directory
[ERROR] Took 5.05 seconds

Please provide an output of pio device list --logical.

I get the following:

pio device list --logical


Obsolete PIO Core v3.4.1 is used (previous was 3.5.1a1)
Please remove multiple PIO Cores from a system:
http://docs.platformio.org/page/faq.html#multiple-pio-cores-in-a-system


Error: no such option: --logical

I’ll try and reinstall to see if that goes away!

I have removed the manually installed v3.4.1 PIO Core now. Now there is only v3.5.1a1 installed with the VSCode PlatformIO. Now when I run pio device list --logical in the built in terminal I get:

pio device list --logical
/

Name:

/boot/efi

Name: efi

/media/paul/Archive

Name: Archive

/media/paul/Machines

Name: Machines

I don’t see /media/paul/JLINK in this list.

When the nRF52-DK is plugged in it appears in the Dolphin devices list automatically, but unmounted, as JLINK. The PlatformIO Devices tab in the VSCode plugin correctly identifies the device as:

/dev/ttyACM0 J-Link - CDC USB VID:PID=1366:1015 SER=000682902707 LOCATION=3-3:1.0

Upload still fails as before.

If I set ‘upload_port = /media/paul/JLINK’ in platformio.ini it also fails as before. Then if I manually open the mount point using the Dolphin file manager and upload with upload_port set to /media/paul/JLINK it works! However, I think this is a sub-optimal process as we should not have to manually coerce the mounting process to be able to upload.

This is a serial port… We can use it only if the board is pre-flashed with special bootloader…


I see that this board has on-board J-Link debugger. We can use it for debugging and programming. Does PIO+VSCode work for this board in debugging mode?

I’ve not tried the debugging mode yet, I’m still evaluating IDE’s to see what I will stick with. I’d live with frictionless build+deploy for now!

We have made a lot of updates to the nordicnrf52 dev/platform and added support for different debug tools and uploader.

Please test a development version of dev/platform and report if it works for you:

[env:]
platform = platform = https://github.com/platformio/platform-nordicnrf52.git
framework = mbed
board = nrf52_dk
upload_protocol = jlink

Possible values for upload_protocol are: jlink, cmsis-dap, blackmagic, mbed.

Please report if it works.