How to reference an USB port via avrdude? - avr

avrdude has the option p which permits you to determine which port should be used.
By checking the USB settings of my USBASP, it says it is connected through the port#0002.hub#0001. So I tried the following:
avrdude -p m168p -c avrisp -P com2 -b 19200
Unfortunately it didn't work:
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
USBASP has been updated to the latest version and the -F option doesn't work either.
Am I referencing the USB port correctly by calling is COM2?
Any ideas on how to make it work?

USB port number have nothing to do with the COM port number. (COM are virtual nowadays)
Basically you want to know which COM port windows uses for your USB device.
Go to your device manager to see what COM port your avr writing device is using:
com port info
You can even change it via your USB device's properties if you want.
(Properties -> Port settings -> Port COM number)

Related

WSL Kernel Netfilter hooks for Pre/Post Routing not available

I'm on Windows 11, WSL2, kernel 5.10.60.1-microsoft-standard-WSL2.
I'm using a RHEL distribution and I'm trying to enable a netfilter NAT rule. The problem is I receive this error if I try to add a rule to the NAT table for Pre or PostRouting:
[root#rhel8 nftables]# nft add chain nat prerouting { type nat hook prerouting priority 0 \; }
Error: No such file or directory
add chain nat prerouting { type nat hook prerouting priority 0 ; }
^^^
My googling leads me to believe that I need to add some kernel configuration in order to make this work, but from what I can tell from the Microsoft defaults, everything appears to be switched on. If there is a kernel guru out there who can give me a hint I'd appreciate it!
For prosperity for anyone who hits this error:
I pulled the microsoft WSL kernel (https://github.com/microsoft/WSL2-Linux-Kernel.git) then copied the ./Microsoft/config-wsl to .config to seed the kernel compilation.
Ran make config to step through the answers until the netfilter section of the compilation, then answered yes to the entire section on netfilter, including NAT etc.
make -j $(nproc)
Once the kernel compiled, I copied the x86 (not x86_64) ./arch/x86/boot/bzImage to something reachable on the windows file system (/mnt/c/users/me/xxxx).
Then make a backup of, then edit your c:\users\me\.wslconfig and update kernel to be the new kernel (remembering that you must use \\ in the path to the kernel e.g. c:\\users\\me\\bzimage_custom. Finally restart WSL to boot the new kernel:
wsl --shutdown
wsl -d mydistro
Then you will have NAT available :).

how to display velodyne points on ROS installed on "Ubuntu on Mac" via Parallels Desktop on macOS?

This is probably easy but I am a noob in networks so please help!
Basically I am trying to display lidar points from my Velodyne VLP-16 on ROS installed on Ubuntu 18.04 which is in turn installed via Parallels Desktop on my macOS.
So I plugged the velodyne's ethernet cable to my MacBook via a usb-C-to-ethernet adapter and set this on my mac:
I can type in my browser this address 192.168.1.201 and I can see the velodyne interface. So it works.
When I now go to "Ubuntu on Mac" via Parallels Desktop and do not change anything in Network->Settings->Wired->Connected so I can see these settings:
... I can still see the velodyne interface via a browser on Ubuntu by typing the 192.168.1.201 address as I can on macOS.
The only problem is that when I wanna run
roslaunch velodyne_pointcloud VLP16_points.launch
it says that:
[ INFO] [1592867527.026682801]: Opening UDP socket: port 2368
[ WARN] [1592867528.028658170]: Velodyne poll() timeout
[ERROR] [1592867528.029191798]: DriverNodelet::devicePoll - Failed to poll device.
so it does not work.
I have tried to look up something similar but I failed cos my knowledge in networks is very limited. Following this tutorial I could not get this command through cos it says:
maciej#ubuntu:~$ sudo ifconfig eth0 192.168.3.100
[sudo] password for maciej:
SIOCSIFADDR: No such device
eth0: ERROR while getting interface flags: No such device
Interestingly, when I change the IP address on "Ubuntu on Mac" to this:
I cannot see the Velodyne interface in my browser on Ubuntu, but I still can on my macOS.
I will just add that when I follow the mentioned tutorial on Ubuntu installed on a PC (not via Parallels Desktop on mac), everything works.
Please help bosses!
After a thorough examination of the network traffic both on macOS and on the emulated Ubuntu using Wireshark on both ends, I realised that there is no Network adapter present in the virtual machine configuration.
Following the answer from Desktop Parallel support, I did:
Ubuntu on Mac -> configure -> hardware -> add device -> network 2 -> source: USB...
and when you check now in Wireshark, you will see the traffic coming from the USB adapter and the ROS driver, via an adequate port, will capture the packets.

Debugging react-native application using WIFI

Could not run adb reverse: Command failed: /home/sofiane/Android/Sdk//platform-tools/adb -s 192.168.1.2:5555 reverse tcp:8081 tcp:8081
When i use port : 8081
adb tcpip 8081
adb connect 192.168.1.2:8081
I have this error :
And when i use port : 5555
adb tcpip 5555
adb connect 192.168.1.2:5555
I have this error :
If you are connected to an Android device over wifi you must do as advised in the last suggestion on the error screen (because adb -s ip:port reverse ... seems not to work):
With your app open, shake the device until you see the developer menu.
Go to "Dev Settings".
Set "Debug server host & port for device" to your development machine's IP at port 8081.
Make sure you have connected on the same network, like in my case I connected my laptop through my phone's hotspot. Of course you also need to have internet access and make sure you have successfully installed your app to your phone using react-native run android. If you have successfully installed your app you may now remove the attached USB cable.
Then on
Windows, just open your terminal (CMD), then type ipconfig, and then press enter.
You will then see the list of your IP configuration.
Your private ip address is the IPv4 Address, something like 192.168.0.10.
On your react native project, run react-native start to start the metro bundler.
When the metro bundler started it will say Running Metro Bundler on port 8081 <- this is the port that you have to connect through.
On your device go to device setting then to "Debug server host & port for device", then type the computer's private IP address plus the port where metro bundler is running, for example: 192.168.0.10:8081.
Click on save then try to reload your app again.
As stated on react-native docs
devices have to be on same wifi in order to work, then go to settings through app by shaking it and in menu select "Dev Settings": Just add pc local address to "Debug server host & port for device" like so 10.0.1.1:8081.
As well adb reverse tcp:8081 tcp:8081 may be required.
In the beginning connect your mobile to pc and run app using react-native run:android command. then run adb shell input keyevent 82 command. It will display a popup window and select Dev Settings.And then go to debug server host &port for device. Then Enter your wifi host ip which is also connect with your PC (use this link to get wifi IP get local IP of the connected wifi)
and get the value of Your Local IP is:*************
and after that IP address add : 8081
if you want to live reload through the wifi use this adb shell input keyevent 82
command and select live reload option.
I had same problem on Windows, I solved it by adding rule for port 8081.
in your case, this may help you:
sudo ufw allow 5555/tcp
What I do when I'm having troubles with the wi-fi connection because my PC at work has firewall rules that changes all the time.
Turn on my "mobile hotspot", to share my connection, with the mobile connected to the wi-fi.
Connect my notebook on the shared network from mobile.
Get the IP that the mobile has generated.
Set "Debug server host & port for device" to that IP at port 8081.
I was able to do without having to connect device and installing app initially.
Open project in Android Studio
Open "Device Manager" in Android Studio
Click "Pair using Wi-Fi" in Device Manager Android Studio
On device -> Settings -> Developer Options -> Wireless debugging -> Enable wireless debugging
On device -> Settings -> Developer Options -> Wireless debugging -> Pair using QR code -> Scan QR code showing in android
Run adb devices from terminal or equivalent to list the device on the same network
run react-native run-android deviceId=xxxxxxxx with xxxxxx the device name of your adb device on same wifi network showing in terminal
There you will have app debuggable from wifi
I had faced the same issue over trying to connect android 4.4 device for debugging with react native application .
you have to disable firewall
then connect over again , it works fine
Happy coding !!

J-Link GDB debugging in CLion

Not long ago CLion added support for Remote GDB debugging and I'm trying to set it up with Seggers's J-Link GDB server.
My setup:
VM VirtualBox running Ubuntu 16.04
J-Link drivers: V6.10
Target chip: nRF51 (ARM Cortex M0)
CLion 2016.2.2
I usually work in windows, but as CLion doesn't support remote GDB in windows I'm trying to make it work running Ubuntu in VirtualBox. I configured the debugger in CLion like shown in the image with a little help from the blog in the link above. The arguments I have used are based on the J-Link documentation (Document: UM08001) and some guessing.
GDB server setup
My problem is that when running the debugger the process just stops and CLion's console outputs:
"Could not connect to target. Please check power, connection and
settings."
I have tried to run JLinkGDBServer from the terminal and then I get as far as this:
/usr/bin/JLinkGDBServer -device nrf51422_xxAC -if swd -speed 1000 -endian little
SEGGER J-Link GDB Server V6.10 Command Line Version
JLinkARM.dll V6.10 (DLL compiled Sep 14 2016 16:46:16)
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: nrf51422_xxAC
Target interface: SWD
Target interface speed: 1000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 5 2016 08:42:09
Hardware: V1.00
S/N: 681666518
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...
Does anyone have a clue of what I'm doing wrong?
You're probably confusing GDB server and GDB itself. Those are GDB options that should be set in the GDB Remote Debug Configuration in CLion, not GDB server settings.
That is, you first run JLinkGDBServer manually, for example, from terminal, just as you've done already, and leave it waiting for GDB to attach. At this moment one should notice the connection port:
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...
Then edit your GDB Remote Debug Configuration in CLion to use the host GDB (most likely /usr/bin/gdb in your case, install it using sudo apt install gdb if necessary), and use the port mentioned above as part of the "target remote" string:
GDB: /usr/bin/gdb
"target remote" args: :2331
Notice the preceding colon in front of the port. This is a shorthand for connecting to localhost using TCP. Just in case, the explicit form is tcp:localhost:2331.
Now you can start the debug session. CLion will start the configured host GDB, GDB communicates to JLinkGDBServer through the specified TCP connection, and finally the GDB server chats with your device.

Cannot start GDBserver using a serial connection

I'm running a small test program on an embedded Linux target (a Freescale i.MX25), which I'd like to debug using GDB. I connect to the system using an FTDI USB-RS232 cable through am Ubuntu VM. GDBserver is installed on the target. I do not have Ethernet or USB support on the target, so I'm trying to use GDB over serial.
When I log into the target using Minicom, I get:
login[1691]: root login on 'ttymxc0'
which I presume means that the console is using ttymxc0. Then, I try to start GDBserver listening for connections from the VM to the test program, residing in /home:
$ cd /home
$ gdbserver /dev/ttymxc0 test
which gives the output (repeatedly):
Remote debugging using /dev/ttymxc0
readchar: Socket operation on non-socket
Remote side has terminated connection. GDBserver will reopen the connection
Is this an error in the way I'm trying to use GDBserver, or something else? Is there another way to debug the program?
You can not use ttymxc0 for two things at the same time (serial console and serial gdb). Disable the getty on that serial line and replace it by the gdbserver.

Resources