Closed ProExpertProg closed 3 years ago
I think this is because WSL doesn't implement the full USB device API. WSL's access to hardware is pretty limited in general...
In the old version of mbed-cmake, I was actually able to mount the drive and set up automatic uploading.
How exactly does it mbed-cmake scan for devices?
Oh right, this is because I switched to using the Mbed Tools python script to do the uploading. It's nice because it scans the list of USB devices and identifies Mbed boards automatically. I guess it doesn't work with WSL though.
If you really have to work under WSL (native Windows development has always worked fine for me), your best bet would be to copy the old version of the MBED upload script into your top-level project. Then rename MBED to something else (HARDCODED_MBED
?) in the file and its filename, and finally enable it in your upload method config file (set(HARDCODED_MBED_UPLOAD_ENABLED)
) and on the command line (-DUPLOAD_METHOD=HARDCODED_MBED
).
OK. I mean it's just a copy operation, we can just call it manual_copy, right?
sure
So I implemented this back but it's currently not working. Have you ever had any problems with the file
command in CMake? If I copy over the file manually in the terminal, it works
So after some more debugging, I think it might be an issue with CMake. If I run the following in the terminal:
# doesn't work
cmake -E copy "/mnt/c/Users/Luka Govedic/CLionProjects/dennis-firmware/cmake-build-debug-hardware/hardware/hardware-test/clock.bin" "/mnt/d"`
# works
cp "/mnt/c/Users/Luka Govedic/CLionProjects/dennis-firmware/cmake-build-debug-hardware/hardware/hardware-test/clock.bin" "/mnt/d"`
The CMake copy
command works for non-mounted paths. However, it stops the current executable so something is happening (which is even weirder).
I'm inclined to just use the native cp
; that's because this upload only really applies to WSL.
# file(COPY "${BIN_FILE}" DESTINATION "${MBED_PATH}") # doesn't work
execute_process(COMMAND cp "${BIN_FILE}" "${MBED_PATH}") # works
Could you make it so that on Linux and Mac it will use cp, and on Windows it will use cmake -E copy?
Sure, if I knew how to detect Windows haha
Oh that's easy: https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/How-To-Write-Platform-Checks See the section I wrote there, "Platform Checking"
Interesting, I'm actually seeing the same behavior on Windows 10 with a NUCLEO_F429ZI board. Calling cp from Git Bash works (as well as dragging the file in from Explorer), but using file(COPY) seemingly causes the board to hang. Looking back, I know I've tested the file(COPY)
method with Nucleo boards on Linux and with LPC1768 boards on Windows and Linux, but I'm not sure I'd ever tried using file(COPY)
on Windows with an ST board, so maybe that's the common factor.
Resolved (for the most part) in #33.
Running this through CLion 2021.1, CMake 3.16, latest mbed-cmake (1.6.2). Build and manual upload works successfully, but the flash-target gives the following error:
What could be wrong?