Test and Debug a driver - visual-c++

All, Forgive me I am the beginner of the WDK development, I was reading some tutorial from msdn in here
and the read says
Typically when you test and debug a driver, the debugger and driver
run on separate computers. The computer that runs the debugger is
called the host computer, and the computer that runs the driver is
called the target computer. The target computer is also called the
test computer.
So I was wondering if the host computer and target computer can be the same one ? thanks.

There is a possibility for live debugging in Windows Kernel debugger. Not all the commands of the debugger will be available (http://msdn.microsoft.com/en-us/library/windows/hardware/ff553382(v=vs.85).aspx).
Another option is to use two virtual machines and redirect the serial ports of those VMs through named pipe or TCP\IP. If you are just beginning and mostly playing with Toaster sample driver - this is more than enough.

It is always advicable to have a host pc and test pc seperate as
when you a developing a device driver you might end up crashing the system multiple times which might lead to hard disk failure and hence if host pc is same as test pc, you would lose all your data.

Related

Radeon developer panel not detecting running program

I have a vulkan application I want to profile (to find the bottlenecks on the gpu for optimizations). I am on linux and amd hardware so I downloaded the linux version of the radeon developer tools. I ran it and created a local server and that seems to work.
I then launched my program, but it does not appear on the list of profiling candidates in the panel.
As you can see the connection is fine (green dot), but no applications are detected. I have tried with advanced mode as well but no luck.
I know for a fact the program is running as I can see it and use it, recompile it... Has anyone run into this problem before?

MPI run on external network

I'm new to MPI and I wrote a program to calculate large factorials over multiple processors. I tested the program on my local network with only 2 machine. ie. a laptop and my PC and its working perfectly.
Now I am trying to run the program over the internet on my friend's PC. Everything is installed perfectly. I already configure the router for port forwarding and I can ssh with to a user account.
I'm using mpicc to compile the program and it works and i also successfully copied the executable file to the external machine through scp. My problem is when i run the command mpirun -hostfile hostlist -np 2 fname. the process is stucked and i get only a blinking cursor on the terminal.
can someone explain me why this is happening?
Thanks.
As soon as you didn't provide any code snippet,
I'll just list what may be the reason, probably there are others too, the best way will be that you debug your code, and see where it is stuck
The reasons can be several
Code issue, wrong handling of special cases
Network issue, wrong configuration for a specific port, firewall
configuration etc.
etc

Debugging (possibly) OpenCV related crash on Jetson TK1

What I am looking for: I need help debugging consistently happening system crashes on my Jetson TK1.
System: I am using a Jetson TK1 board from NVIDIA. Updated to 21.3.4 Grinch Kernel. All drivers installed, libopencv4tegra installed alongside ROS (using hacked deb packages to not overwrite openCV). Everything used to work perfectly in this exact setup.
When the crashes happen: I am running a VSLAM program, which uses a camera connected on the USB port. The program is making heavy use of OpenCV. The program used to run for over 1 month without problems in the current setup. Now, I am getting consistent system crashes which result in a total system freeze. When I am connected over ssh, I loose connection. When I connect a monitor to see what happens on the system while it crashes, I can see everything freeze. The USB port also seems to turn off, since not even USB mouse and keyboard work anymore post-crash. The Jetson stays on though.
Crash Logs: I have tried looking into the /var/log/ logs, but none of them show any messages for when the crash happens.
I have run memtester before. It didn't return any bad memory. While running and crashing, the memory onboard is used at about 60-75% (as shown by "top"). CPU usage is around 60%.
The weird thing is that this exact setup has been running just like this for over a month now.
I need to know: are there any other logs I could find information about the crash in? How could I find out if this is related to a hardware failure or whether there's a software issue?
Thanks
-Marc

How to simulate ThreadX application on Windows OS

I have an application using ThreadX 5.1 as the kernel.
The Image is flashed on to a hardware running an ARM 9 processor.
I'm trying to build a Simulator for the application that can be run on Windows (say XP, 32-bit).
Is there any way I can make it run on Windows, without modifying the entire source code to start calling win32 system calls?
You can build a Simulator for the application that can be run on Windows with "ThreadX for Win32".
"ThreadX for Win32"'s specification is hear.
http://rtos.com/products/threadx/Win32
Yes you can if you are willing to put in the work.
First observe that each threadx system call has an equivalent posix call except for events.
So your threadx program can run as a single process using posix threads, mutexes, etc.
Events can be handled by an external library (there are a few out there).
If you find this difficult in windows then the simplest thing to do is set up a linux vm. I use an ubuntu vm running on Virtual Box. It is very easy to set up. All you will need is the cdt version of eclipse.
Next you need to stub out all of your low level system calls.
This is also easier than you might think. For example, if you have a SPI driver to read and write to flash, you can replace your flash with a big array which is quite easy to work with at this level.
Having said all this, you may get more mileage if your threadx application is modular. Then you can test each module on it's own and you don't need to mess with threads, etc.
As a first approximation this may give you what you need without going the distance to port the whole thing to run under posix.
I have done this successfully in the past and developed a full set of unit tests for a module that allowed me to develop and test it (on my mac) before going to the target. Development is much faster and reliable this way.
Another option you may want to consider is to find a qemu project that supports your microprocessor. With some work you can develop a complete simulator for your platform and then run the real firmware under the emulator.
Good luck.

Converting a driver to linux

I'm trying to write a linux driver to a device that i have the windows driver of (Similar to the case described Here, but a different device)
I'm using Libusb for the communication on the linux side, and SourceUSB as my USB sniffer (on the windows machine). Now I think I've replicated the controls and bulks properly, but I can't really test the linux log against the windows one. I'm running Ubuntu 12.04 on a VM.
So my questions are:
Is there a multiplatform logger? That could really simplify the log compare process.
When I attach the USB device to the VM - I get the VM driver in Windows. Sniffing this device gives me exactly what the device sees, right? I mean - Is this where I want to sniff?
EDIT:
I've compiled my application on windows (libusb is cross platform - A big thanks to libusb developers who did such a good job) and my application worked properly.
When sniffing the VM driver while running my application on linux, I see the requests to the USB as VENDOR_DEVICE instead of CONTROL_TRANSFER and BULK_OR_INTERRUPT. This seems to be the problem if I understand correctly, since this is what the device "sees".
So I guess my problem now is why does Linux sends my requests as vendor.
ANOTHER EDIT: Problem solved:
Listening to the VM driver gave me the wrong requests (I was listening to the VM driver traffic, not, as i wanted, the traffic of the my USB linux driver
Libusb is perfectly multiplatform. It took me a few minutes to get my code to compile under windows, and from there it was pretty easy to debug and compare logs
You can use Wireshark to capture USB traffic. This page explain how to do it for Linux and Windows : CaptureSetup/USB

Resources