WinDbg: Debug outputs missing when debugging via USB Debug Cable - windbg

This is the first time I try to debug a Windows 7 x86_32 target via a USB Debug cable. In thanks to the author of this article I successful set up host and target for a debugging connection.
Unfortunately I had to find out that there is something different, compared to debuggin via serial cable: My application produces debug messages via OutputDebugString(), and I can see them when using the serial debug connection. But if I use the USB debug connection, the messages are missing.
I have no idea what has gone wrong. Is there something special I have to set up or take care about?

Related

TCP retransmission on RST - Different socket behaviour on Windows and Linux?

Summary:
I am guessing that the issue here is something to do with how Windows and Linux handle TCP connections, or sockets, but I have no idea what it is. I'm initiating a TCP connection to a piece of custom hardware that someone else has developed and I am trying to understand its behaviour. In doing so, I've created a .Net core 2.2 application; run on a Windows system, I can initiate the connection successfully, but on Linux (latest Raspbian), I cannot.
It appears that it may be because Linux systems do not try to retry/retransmit a SYN after a RST, whereas Windows ones do - and this behaviour seems key to how this peculiar piece of hardware works..
Background:
We have a black box piece of hardware that can be controlled and queried over a network, by using a manufacturer-supplied Windows application. Data is unencrypted and requires no authentication to connect to it and the application has some other issues. Ultimately, we want to be able to relay data from it to another system, so we decided to make our own application.
I've spent quite a long time trying to understand the packet format and have created a library, which targets .net core 2.2, that can be used to successfully communicate with this kit. In doing so, I discovered that the device seems to require a kind of "request to connect" command to be sent, via UDP. Straight afterwards, I am able to initiate a TCP connection on port 16000, although the first TCP attempt always results in a RST,ACK being returned - so a second attempt needs to be made.
What I've developed works absolutely fine on both Windows (x86) and Linux (Raspberry Pi/ARM) systems and I can send and receive data. However, when run on the Raspbian system, there seems to be problems when initiating the TCP connection. I could have sworn that we had it working absolutely fine on a previous build, but none of the previous commits seem to work - so it may well be a system/kernel update that has changed something.
The issue:
When initiating a TCP connection to this device, it will - straight away - reset the connection. It does this even with the manufacturer-supplied software, which itself then immediately re-attempts the connection again and it succeeds; so this kind of reset-once-then-it-works-the-second-time behaviour in itself isn't a "problem" that I have any control over.
What I am trying to understand is why a Windows system immediately re-attempts the connection through a retransmission...
..but the Linux system just gives up after one attempt (this is the end of the packet capture..)
To prove it is not an application-specific issue, I've tried using ncat/netcat on both the Windows system and the Raspbian system, as well as a Kali system on a separate laptop to prove it isn't an ARM/Raspberry issue. Since the UDP "request" hasn't been sent, the connection will never succeed anyway, but this simply demonstrates different behaviour between the OSes.
Linux versions look pretty much the same as above, whereby they send a single packet that gets reset - whereas the Windows attempt demonstrates the multiple retransmissions..
So, does anyone have any answer for this behaviour difference? I am guessing it isn't a .net core specific issue, but is there any way I can set socket options to attempt a retransmission? Or can it be set at the OS level with systemctl commands or something? I did try and see if there are any SocketOptionNames, in .net, that look like they'd control attempts/retries, as this answer had me wonder, but no luck so far.
If anyone has any suggestions as to how to better align this behaviour across platforms, or can explain the reason for this difference is at all, I would very much appreciate it!
Nice find! According to this, Windows´ TCP will retry a connection if it receives a RST/ACK from the remote host after sending a SYN:
... Upon receiving the ACK/RST client from the target host, the client determines that there is indeed no service listening there. In the Microsoft Winsock implementation of TCP, a pending connection will keep attempting to issue SYN packets until a maximum retry value is reached (set in the registry, this value defaults to 3 extra times)...
The value used to limit those retries is set in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\TcpMaxConnectRetransmissions according to the same article. At least in Win10 Pro it doesn´t seem to be present by default.
Although this is a conveniece for Windows machines, an application still should determine its own criteria for handling a failed connect attempt IMO (i. e number of attempts, timeouts etc).
Anyhow, as I said, surprising fact! Living and learning I guess ...
Cristian.

UART serial access with Rpi 3

I am trying to establish a serial connection between the RPI3 and an Arduino. Because that wasn't working I connected a USB to TTY cable from my laptop to the Rx/Tx pins of RPI. I was eventually able to use PuTTy to connect to it.
I am running Android Things on the RPI and the android code I have running is supposed to be a loopback (reading from UART and writing back what was read).
Here is where I am confused....
When PuTTy connected I was presented with a command line console on the RPI.
How do I get the Rx/Tx pins on the RPI to just be serial connections into and from my application and NOT a way to log into the console?
Is that a bad idea? I suppose if I ever needed to log into the RPI this would make it more difficult...
I figured out what I was doing wrong...
When following the setup directions at the below site I was using the Bluetooth mode instead of the Application mode. When I followed the directions for Application mode I was able to start using UART0 for serial comms
Set the console attribute to the following in cmdline.txt:
console=tty0
Add the following line in config.txt:
dtoverlay=pi3-disable-bt
Remove the following lines from config.txt:
enabled_uart=1
core_freq=400
https://developer.android.com/things/hardware/raspberrypi.html#disabling_the_console
Beginning with Developer Preview 3, in which USB-Serial devices support added, You can use external USB-UART dongles like this instead of UART of Raspberry Pi 3.

What is the AT command to reset USB cellular modem?

What is the AT command sequence used to reset a USB cellular modem?
Is there a single AT command that can be used? Or does it require a sequence of several in order to reset a USB cellular modem?
I have a Huawei E272 and E220 however I am also interested in a general command sequence if there is any standard AT command.
Resetting the modem is a manufacturer-specific AT command.
There is a spec available online for Huawei AT commands here.
Look at section 3.10 +CFUN
The EXECUTION command is used to set the MS mode or restart the MS
AT+CFUN has 2 parameters:
AT+CFUN=[fun[,rst]]
These 2 parameters fun and rst are defined as follows:
fun:
0 Set as minimum functionality mode (set the RF off but keep
the SIM power on, previous mode must not be offline)
1 Set as online mode (default value) (previous mode must not be offline)
4 Set as offline mode (previous mode must not be FTM)
5 Set as offline FTM (previous mode must be online)
6 Reset MS (previous mode must be offline)
7 Set as RFoff mode (about radio frequency)
rst: Whether to restart MS before setting
0 Not restart MS before setting. (Default)
1 Restart MS before setting. (fun must be 1)
There seems to be a generally used or defacto standard AT command for turning off and turning on a USB cellular modem.
To turn the modem off use: AT+CFUN=0 and to turn the modem on use: AT+CFUN=1. The AT command must be terminated by a carriage return and it must be sent through the Virtual Serial Port that is assigned to the USB modem.
I used the following procedure to test with a PANTECH UML290 USB cellular modem with Verizon as the carrier.
First step was to determine the Virtual Serial Port in use through which I would send the AT commands. I used the Device Manager application from the Control Panel to find the USB modem and to then see what COM port it was using.
Next I used the HyperTerm application to open a connection to the Virtual Serial Port assigned to the USB modem as shown in Device Manager. The HyperTerm application is an older modem and serial ports application that came with Windows XP and earlier. For Windows 7 and later see HyperTerminal Alternatives for Windows 7.
I then used AT+CFUN=0 to turn off the USB modem. Then I used ipconfig /all to examine the LAN adapters in my system which showed the PANTECH UML290 as "Media disconnected"..
I then used AT+CFUN=1 to turn the USB modem back on. I used the ipconfig /all command to display the status of the LAN adapters in my system. After using the command a second time after a few seconds wait, the displayed status showd the PANTECH UMO290 up and running..
For a fuller description of the AT+CFUN=0 command see page 12 of AT Commands GSM Reference Guide from MultiTech Systems which has this to say:
This command selects the mobile station’s level of functionality. When
the application wants to stop the product with a power off, or if the
application wants to force the product to execute an IMSI DETACH
procedure, then it must send: AT+CFUN=0 (equivalent to AT+CPOF). This
command executes an IMSI DETACH and makes a backup copy of some
internal parameters in SIM and in EEPROM. The SIM card cannot then be
accessed. If the mobile equipment is not powered off by the
application after this command has been sent, a re-start command
(AT+CFUN=1) will have to issued to restart the whole GSM registration
process. If the mobile equipment is turned off after this command,
then a power on will automatically restart the whole GSM process. The
AT+CFUN=1 command restarts the entire GSM stack and GSM functionality:
a complete software reset is performed.
This description appears to apply to how this AT command is generally implemented by USB cellular modem providers.
Addendum I: Command Line Utility
I wrote a simple command line utility with Visual Studio C++ that can be used to send a command string to a serial port. The source is located in my Github repository at https://github.com/RichardChambers/writereadport
The utility can be used in a shell or command file and has both a command line interface for a single AT command or a console mode. It is primitive but does the job I needed at the time.
ITU V250 (https://www.itu.int/rec/T-REC-V.250-200307-I/en) specifies ATZ as beeing the reset command:
6.1.1 Reset to default configuration
Syntax
Z[< value>]
Description
This command instructs the DCE to set all parameters to their factory defaults(...)
If you issue the command ATZ, you should have you modem reset and get an OK. Read the spec for more information about the <values> parameter if needed.

How to connect Simulink to GDB Server and then Segger J-Link via USB

I have the Energy Micro EFM32 ARM dev board (EFM32LG-DK3650) that I am trying to connect to with Simulink/GDB Server. The GDB Server connects just fine to the EFM board. It appears that Simulink will not talk to the GDB Server. Has anyone tried connecting Simulink to the GDB Server and had success...other than using any Board Support Packages?
I am using External Mode set in the two places required.
This is the error I receive from Simulink:
Error occurred while executing External Mode MEX-file 'ext_serial_win32_comm': Failed to connect to the target. A time-out occurred while waiting for the first connect response packet. Possible reasons for the time-out: a) The target is not switched on. b) The target is not connected to your host machine. c) The application for the model is not running on the target. You might have clicked the Stop button.
Component: Simulink | Category: Model error
I have been searching for days and reading everything in sight. It appears either that no one else has done this, or had this problem.
Thanks for any help.

Sockets won't connect after Windows 8.1 update

I am currently working on a project that involves the use of sockets. The program was working just fine, but after a windows 8.1 update on my computer, either the client socket is sending out a signal to be accepted or the server socket isn't receiving the signal so it can accept. I tried to use it on my emulator and it worked just fine. In addition, I have updated my GPU drivers to see if this could be fixed, but they still won't connect. The program doesn't crash and give me an error; it just sits there and waits. Does anyone have any ideas? Perhaps the update is blocking my peer to peer connection? Any help is much appreciated. Thanks.