No such file or directory: '/opt/media'

Compilation was OK !
Then it Reset the Serial Port /dev/ACM0 (!!...)

File "/home/jluscher/.arduino15/packages/rp2040/hardware/rp2040/2.0.2/tools/uf2conv.py", line 410, in
Resetting /dev/ttyACM0
Converting to uf2, output size: 147968, start address: 0x2000
main()

But it was "looking for drives" ??

File "/home/jluscher/.arduino15/packages/rp2040/hardware/rp2040/2.0.2/tools/uf2conv.py", line 371, in main
Failed uploading: uploading error: exit status 1 drives = get_drives()
File "/home/jluscher/.arduino15/packages/rp2040/hardware/rp2040/2.0.2/tools/uf2conv.py", line 262, in get_drives
for d in os.listdir(rootpath):
FileNotFoundError: [Errno 2] No such file or directory: '/opt/media'

... and died while looking for a directory called /opt/media

I have no idea why this started... latest update for Arduino IDE ver: 2.0.0-rc8 ??

Hi @jluscher. This error occurs when the uf2conv.py tool used by Earle F. Philhower III's "Raspberry Pi Pico/RP2040" boards platform for uploading can't find the board.

You can learn more about it here:

It doesn't seem to be anything related specifically to the Arduino IDE. I just did an upload to my Raspberry Pi Pico using the "Raspberry Pi Pico/RP2040" boards platform with Arduino IDE 2.x on my Linux machine without any problem, so it is possible to do.

I recommend you to focus your attention on your operating system's handling of mounting the board after it is put into the UF2 mode that causes it to appear to your computer as a flash drive.

Thank you for your reply.

The 'rc8' has been working for weeks now with the code, and the RP2040
and this computer, so I don't have any doubt that it is possible to do. :wink:

Something has changed - and after a successful compilation, with the serial port connected(!), there was a "Reset" ... (I don't remember that happening before!) ... after which the ttyACM0 (USB serial port on my Linux distro) became disconnected.

I'll try some more (crazy?) random things, hoping to figure out what is going on, but the error messages, especially referring to "Line 410" in uf2conv.py, etc. ... all have me bamboozled.

I couldn't find source for uf2conv.py, and probably couldn't make sense of it anyway ... and certainly have NO idea why it was looking for "directory /opt/media" (or what that is about). The 'ttyACM0' (USB serial) is in the '/dev' directory.

Sorry for the lack of better clues, but I wish that I could make sense of why this suddenly started happening.

I'm thinking I'll stop working with the RP2040 and just develop the program for gcc on Linux. The RP2040 has been difficult for debugging MY code with the connecting, resetting, downloading, editing, etc. Perhaps the IDE will be working more reliably in a few months. :frowning:

James

I am not very experienced with the Earle Philhower boards platform (most of my RP2040 experience is with the official "Arduino Mbed OS Nano Boards" platform and my Nano RP2040 Connect board), but I believe this is only referring to the board being put into UF2 mode so the upload can happen.

I see the same thing when I successfully upload to my Pico using the Earle Philhower platform. It may be you just never looked closely at the output before because you weren't having any problems.

This is normal during an upload. When the board goes into UF2 mode it no longer presents a serial port. You will see the same thing if you hold the BOOTSEL button while you connect the Pico to your computer with a USB cable and then release the button. A drive should mount, but you will no longer have a serial port.

The reason for this is the USB CDC serial port is produced by some code that runs in the background of your sketch program. But when the board is in UF2 mode the sketch program is not running. This also means that if your sketch code disables or breaks the USB code, you will no longer have a serial port. This is normal and expected with some programs, but can also happen accidentally in some cases.

It is at the path shown in the error message:

Note that /home/jluscher/.arduino15 is hidden by default (as is the case with all folders and files starting with a . on Linux. But it does exist.

Again, I very much doubt the problem has anything to do with the Arduino IDE. If you put all your focus there, you may miss the true cause.

But by all means, download the stable Arduino IDE 1.8.19 and give it a try.

Thank you again !
I'm headed off to help a friend with a "Black Screen on power-up boot".
New computer, Win11. Not my usual thing but he definitely needs help. :frowning:

A way to "pay it forward?

Thanks for the tips and suggestions. I'll see what I can do with them.

James

1 Like

I was (finally !) able to determine that my computer has no /opt/media folder.
The RasPi DID put the Pico2040 into 'Boot' mode it seems, and the attached dmesg 'log entries' suggests it has been given device 'sda' and folder(?) sda1.

Gparted shows that the device is indeed /dev/sda1 - fat16 -
/media/jluscher/RPI-RP2 - 127.85 MiB unused

I hope this might clarify what is going on with the Arduino IDE
when it reports that /opt/media isn't a folder ... why look THERE ?

Thanks, James

It is not really accurate to say that Arduino IDE is reporting this.

Arduino IDE just runs the uf2conv.py tool provided by the 3rd party Earle F. Philhower III "Raspberry Pi Pico/RP2040" boards platform and then prints the output from the tool. The IDE doesn't know anything about the tool or the output. This is because it is a general purpose tool that is intended to support any arbitrary boards architecture and toolchain. There is nothing special coded into the IDE for this tool or boards platform.

I don't have enough knowledge about this subject to provide a specific reason. But I can tell you that it is looking there because that is what the code in the uf2conv.py Python script is written to do:

https://github.com/earlephilhower/arduino-pico/blob/2.3.1/tools/uf2conv.py#L251-L255

rootpath = "/run/media"
if not os.path.isdir(rootpath):
    rootpath = "/media"
if not os.path.isdir(rootpath):
    rootpath = "/opt/media"

So it first checks to see if you have a /run/media folder on your computer. If not, it falls back to /media. If that folder doesn't exist, it falls back to /opt/media.

If none of those folders exist, then it fails with the error No such file or directory: '/opt/media'

THANK YOU :+1:
This clarifies the additional question that came up after the downloading
for 'rc9' for Arduino IDE this morning. I had made some last minute
changes to the uf2conv.py file on my machine, and backed the changes
up - prevent their being overwritten by the new download - and after
that the "upload" to the RasPi Pico WORKS. !!
... BUT ... it displayed a series of my debugging messages (!)
which really confused me. :crazy_face:
So in with the debugging print statements it now looked in the
correct place - with the [USER] folder included after the /media.

Now I guess I'll have to pass this info along to the
earlephilhower site with the 'suggestion' that they consider
some changes for linux machines.

At least I can again get back to the work I was doing on 6-22
when I couldn't do an "upload" anymore ... if I can remember
just what I was working on ... back then. :rofl:

Thanks once again for your help in clarifying what is going on
with this code.

James Luscher

ANSWER: For Linux machines (Ubuntu, Pop!_OS, ...) the
uf2conv.py program:
(arduino-pico/uf2conv.py at 2.3.1 · earlephilhower/arduino-pico · GitHub)

Needs correction to include a line (or more :wink: ) that looks for
the /media/[USER] folder for the RPI-RP2 device for uploading
to:
tmp = "/media/"+os.environ["USER"]
if os.path.isdir(tmp):

You are welcome. I'm glad you were able to find the solution.

Thanks!

The same error occurs if you installed the Arduino IDE using Flatpak. Flatpak restricts an application's access to the file system so the IDE cannot see the contents of the /media directory. To fix this problem you can configure Flatpak to allow the Arduino IDE to access the whole file system with this command:

flatpak override --user --filesystem=host cc.arduino.IDE2

Solution also cross-posted on the Arduino-Pico Github with instructions for older IDE versions too.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.