Sony's Developer World forum

    • Home
    • Forum guidelines

    Upcoming maintenance 

     

    Dear Customers and Partners.

    This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.

    This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.

    We apologize for any inconvenience.

     

     

    Developing with Spresense SDK on WSL2

    Spresense
    2
    3
    1460
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Sean Phillips last edited by

      Re: SPresense SDK on WSL2 ?

      I came across this old forum post as I was investigating potential avenues for developing Spresense apps in WSL2. I followed along with the forum post and got to the point where I have the SDK setup in my WSL2 instance and a available /dev/ttyUSB0 device.

      However, attempting to flash the bootloader on the device returns the following error:

      ~/*/spresense/sdk$ ./tools/flash.sh -l /home/*/spresense/firmware/spresense -c /dev/ttyUSB0
      Cannot open port : /dev/ttyUSB0
      Cannot configure port, something went wrong. Original message: OSError(22, 'Incorrect function.', None, 1)
      

      I'm going to be spending some time looking into this issue and seeing if its possible to diagnose and resolve this error. However, I was curious if anyone had any success with developing on WSL2 and if they had any insights?

      S 1 Reply Last reply Reply Quote
      • S
        Sean Phillips @Sean Phillips last edited by Sean Phillips

        @Sean-Phillips
        After a bit more digging I was able to figure out the issue (at least with running the flash.sh command to upload the bootloader). After applying the changes below, I was able to flash the bootloader

        To give a tl;dr for folks needing a quick answer:

        • There is logic in the flash.sh script that will run flash_writer.exe if your environment is in WSL2. If the script utilizes this executable, there will be an error when attempting to write to /dev/ttyUSB0.

        You can make the following adjustments to your flash.sh script for a quick fix:

        # In File: /home/*/spresense/sdk/tools/flash.sh Comment out the following lines
        @ lines 84-91
        + # if [ "${PLATFORM}" == "linux" ]; then
        + # 	if [ "$(uname -r | grep -i microsoft)" != "" ]; then
        + # 		# WSL/WSL2 is a linux but USB related SDK tools
        + # 		# should use windows binary.
        + # 		PLATFORM=windows
        + # 		EXEEXT=".exe"
        + # 	fi
        + # fi
        

        This will prevent the flash.sh script from utilizing the flash_writer.exe file in the WSL2 environment. Rather, it will now just utilize the Linux binary version of the flash_writer.

        I do know for a fact that running Windows binaries is possible in WSL2, but since the device is connected into WSL under /dev the flash_writer.exe binary cannot operate on it (Just a hunch).

        C 1 Reply Last reply Reply Quote
        • C
          CamilaSouza DeveloperWorld @Sean Phillips last edited by

          Hi, @Sean-Phillips

          Thanks for sharing your solution here!
          It will be helpful for other developers in the future.

          I will try this myself to validate the issue so the documentation can be updated.

          1 Reply Last reply Reply Quote
          • Referenced by  G gyps 
          • First post
            Last post
          Developer World
          Copyright © 2021 Sony Group Corporation. All rights reserved.
          • Contact us
          • Legal