How would I use Arduino-CLI in WSL? - windows-subsystem-for-linux

I recently started playing with an ESP8266 and wanted to try uploading to it using WSL. I found the Arduino-CLI command and followed some tutorials but couldn't figure out how to upload to the board. The command I tried running is arduino-cli upload -p /dev/ttyS5 --fqbn esp8266:esp8266:arduino-esp8266 Testing because I know that the board is an ESP8266 and the is connected to COM5 on the Windows Arduino app. The code compiles and attempts to connect to the board, but cannot get past that part.
This is the code I was trying to upload.
void setup() {
pinMode(0, OUTPUT);
}
void loop() {
digitalWrite(0, HIGH);
delay(1000);
digitalWrite(0, LOW);
delay(1000);
}
When I execute arduino-cli board list, it shows this.
Port Protocol Type Board Name FQBN Core
serial Unknown
I'm using Windows Terminal for Ubuntu 20.04 and just installed Arduino-CLI.
I also am not sure how to ask stuff cuz it's my first time using StackOverflow, so pls tell me if I'm doing something wrong :)
Edit: So it turns out that I was uploading using the wrong core. I ended up trying every single core listed by arduino-cli board listall esp8266 and it eventually worked with esp8266:esp8266:nodemcuv2 instead of esp8266:esp8266:arduino-esp8266.

Just educated guesses here from my understanding of WSL rather than Arduino.
I'm assuming that you are using WSL2, which doesn't have access to most Windows hardware, including the serial ports.
If that's the case, two options that you might try:
WSL1 does have some better direct hardware access, at the expense of some kernel compatibility (since it attempts to translate syscalls rather than virtualize them). You can try converting the distribution to WSL1 via:
wsl -l -v
# Confirm distribution name
wsl --set-version <distro_name> 1
You might want to back it up first with wsl --export <distro_name> backup.tar.
As mentioned in the comments, you should be able to use the Windows toolchain. You can even run this under WSL2, since Windows commands can be executed there through interop (and would have hardware access). Remember to use the full executable, like /mnt/c/arduino-cli/arduino-cli.exe. And also you'll need to convert any Linux/WSL paths to their Windows equivalent with wslpath.

Related

What is the best way to remotely edit a file using VS code?

Currently, I have two machines, one with Ubuntu in the company and one with Mac OS at home. Sometimes I would like to work at home while accessing the Ubuntu machine in the company. I can ssh into the Ubuntu machine and navigate and compile there. However, when I actually want to edit some cpp source codes, I realize that the editor (VS code) is actually opened in the Ubuntu machine, so I cannot view it from Mac. What should I do if want to edit files remotely on my Mac through VS code?
Though many of the answers mention using version control tools like git, it can be hard to use in my specific case. The problem is that the building environment of my company is Linux, so most of the building tools I have can only run on Linux. This means that I can only compile my source codes in Linux. If I use git, then every time I want to compile and debug my codes, I have to commit and push with my Mac, and then pull and test on Linux. This can be time consuming if want to incrementally modify, test and debug my codes.
Use some version control system like git. Then you might edit and compile at home (provided your code is portable between Linux & MacOSX, e.g. because it is POSIX compliant).
You could install some X11 server on your Mac and use ssh -X to access the remote Ubuntu machine (then run a GUI or editor remotely, e.g. ssh -X remotelinuxhost.company.com emacs). However, that requires good bandwidth and latency between your home computer and the remote one.
BTW, you might use some other source code editor, like emacs (it is capable of remote editing) or vim.
Since Linux and MacOSX are both POSIX systems, it is usually (but not always) easy to port source code from Linux to MacOSX and write source code compilable on both systems. BTW, many Linux frameworks (e.g. Qt, GTK, POCO, Boost, etc...) and build systems are usable and ported to MacOSX. Some Linux system calls (listed in syscalls(2)) are not available on MacOSX (e.g. signalfd(2)...)
Of course you could install Linux (perhaps inside some VM) on your Apple laptop.

Running a program written for freeRTOS (RTOS) in virtualmachine as a binary

I got a simple program written for freeRTOS (implements a timer).
I want to run this program in an empty virtual machine (VirtualBox, or QEMU, or something else).
I need to make a binary file that can run in and empty VM.
Any advice or direction of how can i do this?
I checked many stuff on freeRTOS homepage but couldn't find something useful.
For virtual box, you will need a binary of freeRTOS that is x86 or amd64 compatible. Check if this is of any benefit for you.
You can check this link, as I understand it's a simulator for freeRTOS which may enable you to test it without a virtual machine.
For QEMU, check this link
Emm..., if you need run just binary file without any OS started you can use qemu for that. Just pass your binary through option '-bios' into qemu. And after qemu will start it to run. Also use '-S -s' options in for enabling gdb server in qemu. After you can connect to qemu with gdb client and debug you binary step by step.

Can't flash the module — 'Please insert disk'

I recently got a new Mbed board - this one is MTS Dragonfly. I can't get flash-disk to show up correctly, and I am wondering if I have got a DOA module, or I am doing something wrong. Does this happens to other Mbed boards?
I have installed drivers from manufacturer website and do have a working serial connection, which defaults to the cellular module. However the flash disk does not show up correctly. Unlike other Mbed boards, I am greeted with a message "please insert disk" and I see no file system.
Interesting part is that the mbed microcontroller - that is the one doing the programming - is on a separate development / breakout board. The target is a separate module that is meant to be used in production.
If I do not insert the target into the development board, and connect development board to the PC, I get the same error. I have looked at diskpart, and when no target is present, it shows up as a 16 KB disk with no partitions or volumes.When the module is inserted, diskpart reports ~512 KB of space, also with no partitions. Thus I guess that I am plugging in the module correctly.
I have seen user discussions for a 'bricked' mbed board (damaged file-system), and this situation looks similar to me.
I tried diskpart to create a partition, or clean the disk, and it throws an IO error.
This question on mbed site
I just tested all of my Mbed boards and discovered that this is a regression in Windows 10 anniversary update.
MTS-Dragonfly and another board, Delta DFCM-NNN40, do not show up with a valid partition on any of my Windows 10 machines. I have a couple of FRDM boards and those work fine.
I tested Ubuntu, and it has no issue displaying the disk drives or programming the boards. I have not tested other versions of Windows. A workable solution is is to use Ubuntu in VirtualBox, and pass it control of the USB device.

avrdude xmega256a3 can't program usersig?

I use avrdude on osx to do development for an xmega256a3. It's wonderful, it lets me flash my target just fine. However, when I try to use it to program the usersig block, it doesn't work so well. I was initially excited by some early success with it, but found subsequent flashes weren't working.
Through testing, I determined that if my usersig file was for all 0's, it worked fine. But all FF's didn't work. Given what little I know about flash, these leads me to believe that I'm either missing an option or avrdude isn't doing a complete job for what it needs to do here.
The command I'm using is
avrdude -p atxmega256a3 -P usb -c avrispmkii -e -U usersig:w:mySig.hex
Using AVR Studio 4 on a Windows box, I am able to program any of these files to the usersig flash block.
My question boils down to is this possible? if so what option/incantation am I missing? Or am I out of luck for programming usersig for this processor with avrdude?
(I'm using version 5.11.1 from the CrossPack guys)
It turns out that old versions of avrdude indeed did not support this. It requires a page erase of usersig, and that was not supported until version 6, which is due out soon. I've tested with svn builds of it, and with a two line patch submitted to day, it does the job.

Can I use Kinect on a Mac?

Studying vision, I would like to play with the Microsoft Kinect.
Can I use it on my Mac?
I have not found any Library for Mac and fear virtualization on my laptop to use Linux.
I've accessed Kinect data on OSX using openframeworks and the ofxKinect addon (which uses libfreenect and libusb).
It's not the only option, just I've used and worked 'out of the box'.
Try downloading the Zigfu Dev Bundle for mac (http://www.zigfu.com) - that should get you up to speed with kinect development on mac.
Using Kinect on Mac is as easy as ordering Latte.
But there is also a lot of confusion on the Internet and sites that seem to be old and give you the wrong advice such as installing a separate sensor library in addition to OpenNI. Just go to the basic website and download SDK for your MAC:
http://www.openni.org/openni-sdk/
You might need to have prerequsities though I assume you have already installed them, such as:
sudo port install libtool
sudo port install doxygen
restart comp
sudo port install libusb-devel +universal
Troubleshooting:
"sudo rm -f /opt/local/lib/libusb-1.0.0.dylib"
"sudo port clean libusb"
"sudo port install libusb +universal"
No need to compile anything. You should be able to run ./Samples/Bin/SimpleViewer right away after you run sudo ./install.sh.The PROBLEM might be that you have already tried to run it unsuccessfully and put a camera in the wrong state. I have seen errors such as USB intercase cannot be set etc. as a side effect.
Running your code in Eclipse is a different story and may require a few extra steps and changing your Ubuntu code (using openni namespace, different includes, etc.)