Failure to loadfile using JLink to nRF51822 - cortex-m

I have built a PCB that uses the nRF51822 (Nordic's cortex-m0 + BLE SOIC). I am failing to load the binary onto the chip. I can:
connect to the nRF51822 on my mac using the JLinkExe.
execute the erase command in JLink
I have a small binary called LED_TEST.hex that I attempt to load. No matter how many times I run loadfile, I get the message:
Downloading file [LED_TEST.hex]...Info: J-Link: Flash download: Restarting flash programming due to program error (possibly skipped erasure of half-way erased sector).
Info: J-Link: Flash download: Skip optimizations disabled for second try.
Error while programming flash: Programming failed.
I'm looking for ideas on how to best debug this. I have files that I logged the SWD traffic into. I am new to SWD traffic, and there are A LOT of records...so i'm not sure where would be the best place to focus within the SWD traffic in order to tip me off why this is happening.

I use MBED platform and REDBearLab's dongle, which is almost a free alternative solution.
You can refer this one: http://www.instructables.com/id/16mm-Bluetooth-69-DOF-Gyroscope-Wearable-Board-tal/
hope helpful

Related

Error in initializing ST-Link Device

I am currently using the ST-Link debugger to program my STM32F3 Discovery Board. The IDE that I am using is Atollic TrueStudio 5.5.2 but now I am facing a very weird problem which is I keep on getting the message " Error in initializing ST-Link Device. Reason : (-1) Failed to connect to device . Please check power and cabling to target." whenever I want to download the program into my STM32. I had tried some solutions that I found from internet but the problem still exists. Anyone had faced this problems before? Any suggestions will help. Thank you.
Here is the solution I found but can't work for me.
http://www.kerrywong.com/2012/08/02/the-dreaded-cannot-connect-to-st-link-error-message/
You could try the following.
Make sure that you have installed the right version of the driver (32 or 64 bits).
If you are using an external ST-Link, make sure that you connect VCC, GND, RESET, SWDIO and SWDCLK.
If you are using an external ST-Link, make sure that Atollic is using the right one. You may have 2 ST-link connected (the external and the embedded one).
Ensure that the ST-Link is setup in SWD mode and not in JTAG.
In Atollic, you could also change how the ST-Link connects to your target. Try different combinations, for example Connect under hardware reset.
In the debugger tab, make sure to select SWD, not JTAG.

CUDA cross-compiling error! cuda-gdb error message RSEG1058

I'm new in this CUDA and parallel computing staff and I have a recent problem. I have an Ubuntu 12.04 system which is host and Jetson TK1 as the target. I'm using Nsight Eclipse to write, edit and compile the algorithms. I'm using SSH protocol to connect TK1 from the host computer.
When I try some file transfer operations it's okay always. However, sometimes the cross-compiling process sucks and errors "Connect to ubuntu#192.168.0.94 was cancelled" having title "RSEG1058". I don't understand the problem because this problem occurs 75% of the time. Sometimes it works perfectly. Can you help me please? I can give another info if it's needed. BY the way, I also found another possibly problematic detail. When I try to change the configuration of the run from the option "Run Configurations" found in the arrow near the RUN button, I discovered that we can change the library and toolkit path which is set in the first place. What I saw in that window was that cuda-gdb file has a red-cross icon with "Operation failed. File system input or output error" message. You can see the image and understand what I'm talking about. I don't know whether these two things are related or not, but I'm tired to try to catch the perfect timing all the time.
Try stopping dbus daemon (by issuing "sudo dubs stop") on the TK1 board or recompiling sshd without ConsoleKit integration.

QtSerialPort example fails [closed]

I am using Qt 5.1 and when my app (which worked using QextSerialPort in v4.8.4) failed to communicate, I tried the example in ...\5.1.1\Src\qtserialport\examples\serialport\terminal. And that fails too.
I have a simple USB dongle that emulates a COM port. If I use RealTerm, I can send AT commands to it and get back OK just fine.
But the terminal example that comes with Qt does not communicate with it. I looked at an API snooper, and I am getting an unsuccessful return with error of "997:Overlapped I/O operation is in progress" for WaitCommEvent and WriteFile.
I am running it on Windows 7, and I copied the exe and DLLs over to a Windows 8 machine, and it failed to communicate as well (though I didn't do the API snooping there).
Anyone have any ideas what to try? How can the unmodified example app just plain fail? I am befuddled.
The terminal example should work. You can track the issue down by first getting the cwritersync example work.
If that is not working, try to make a loopback between the RX and TX lines which are usually the 2nd and 3rd pins of your 9-pins serial port.
Having got that working, you can go further, and try to use the cwriterasync example which is a step closer to what the terminal example is using.
Once, that is working, you can realize what you would have done wrong with the terminal example. It might still be a QtSerialPort bug, but in that case we need all your details about the hardware environment.
Also, please make sure in that case whether or not the terminal example works fine for instance on Unices.
Please try the Qt 5.2 with the available QtSerialPort module (or try to build a last version of the QtSerialPort from git).
I have a simple USB dongle...
What is dongle model? VID/PID?
...return with error of "997:Overlapped I/O operation is in progress..
it is not an error.

Debugging reversed Android application

Let's assumed I have a malware application I got from a device and reversing it using smali or dedexter or dex2jar is ok, but I want to actually debug it and not just perform static analysis.
Is it even possible? I'm not sure how the dalvik VM debugging capabilities work since they should know when single stepping which line of code belongs to which dalvik opcode line, I'm not sure where that meta data resides, anyone has experience with it?
Of course i can try dex2jar and create an eclipse project, but I'm looking for a way to do it from dalvik as well, meaning being able to step through dalvik byecode lines.
Couldn't find any open source project that does that, I'm not sure even Ida Pro allows it.
Anyone got a clue?
You can certainly do that, and debug the malware app without problem. Ida allows you to do it in a very smooth and gentle way, you only need to open the classes.dex inside the apk to IDA PRO and configure the Davilk debugger. But you could also do this in the same way that you would do it if you were writing the application using eclipse for example.
Only restriction,since the application manifest doesn't allow you to debug it (let's suppose the worst scenario and a smart malware), you need to have an engineer device so that you can attach your IDA Pro or Debugger , I mean a device where
$ getprop ro.debuggable
1
$ getprop ro.secure
0
It is also extremely easy to meet those conditions, if you can unlock the bootloader of your device and edit you ramdisk setting ro.debuggable=1 and ro.secure=0 inside the initfiles.
Alternatively, if you device were rooted, you would be able to use setpropex to easily change read only properties in this way.
# ./setpropex ro.debuggable 1
# ./setpropex ro.secure 0
github to setpropex
https://github.com/poliva/rootadb/blob/master/jni/setpropex.c
I did not try the approach but it's possible. To do that you need to download old versions of apktool 1.4.1 and netbeans 6.8 It's claimed that on newer versions the approach does not work.
You can watch the video here how to do this and read also this article which describes how to perform debugging using smali codes.
I read about the approaches on a popular russian IT webpage. Here are the links to these articles: first and it's extension. If you know russian, there are step by step instructions what to do to perform debugging. If you don't Google Translate can help you to catch the idea.
If you there are some points unclear I'll try to help you with them.

Android: Kernel Debugging with KGDB

I'm trying to do kernel debugging for my Nexus One, and have been following instructions from http://bootloader.wikidot.com/android:kgdb. I was wondering if someone has actually got this to work? And has anyone done a more up to date solution for using KGDB to debug the kernel?
I found this post when I was looking for information of KGDB on Android so, despite it being a few years old, I thought it worth posting a link to some work I did to get this up and running on the Nexus 6.
http://www.contextis.com/resources/blog/kgdb-android-debugging-kernel-boss/
I hope this helps anyone else looking for similar answers.
Edited following feedback (thanks all):
To get this working I had to make a UART debug cable based on this Accuvant blog. This is quite a simple circuit which consists of a FTDI 3.3v basic breakout (available from SparkFun at the time of writing), as well as 4 resistors (2 x 1K Ohm, 1 x 1.2K Ohm and 1 x 100Ohm), and a 4-element Tip-Ring-Ring-Sleeve (TRRS) headphone jack. The resistors are essentially providing a voltage divider to reduce the 3.3v down to something a little safer for your phone. By inserting the audio jack with the other end connected to your circuit board, the audio subsystem recognises that a voltage (~2.8V) on the one of the pins and it knows to provide a UART interface via that cable. The FTDI breakout plugs into your PC via USB and from here you can access console messages via a terminal emulator like minicom. However, you now have a serial interface through the same mechanism and that's what we can use for a KGDB connection.
So at this point some relatively minor changes are required to the Nexus 6's serial driver (msm_serial_hs_lite.c) to support KGDB (specifically, the ability to perform atomic character I/O operations). I just ported these changes from the Linux Kernel mainline code as a chap called Stephen Boyd had done the hard work to the full MSM (Qualcomm) serial driver msm_serial.c. His changes can be found here or just search for "msm_serial: add support for poll_" on Google. The port wasn't difficult and my code can be found on github.
Aside from that you need to be able to build a custom kernel for your N6 which google provides lots of information on. You then need to create a boot image which contains the KGDB modifications in the github repo. I took the stock kernel from https://developers.google.com/android/nexus/images, extracted it (using abootimg -x) and then used the following command to repack it with my custom kernel (zImage-dtb) and additional command line params to ensure KGDB would be loaded and point to my serial port like so:
abootimg -u boot.img -k zImage-dtb -c 'cmdline=console=ttyHSL0,115200,n8 kgdboc=ttyHSL0,115200 kgdbretry=4'
With my boot.img created I could boot into it using the command fastboot boot boot.img, open an adb shell and then trigger a breakpoint in the Android kernel using the command:
echo -n g > /proc/sysrq-trigger
It is worth mentioning for completeness that you need superuser privileges to access /proc/sysrq-trigger so you need to have root.
With the phone halted, and your debug cable connected, launch a version of GDB for ARM on your host PC with your uncompressed kernel as an argument (e.g. arm-eabi-gdb ./vmlinux). Note: I'm running Ubuntu 14.04 and using arm-eabi-gdb from the 'prebuilts' directory in my AOSP source repository. Finally, enter the following commands:
set remoteflow off
set remotebaud 115200
target remote /dev/ttyUSB0
All being well this should immediately break into the kgdb breakpoint (that your write to /proc/sysrq-trigger produced) and you can start debugging.
I know that you've already asked a question at the Android Kernel Dev list and got no answers, but did you search through the archives for posts about kgdb and debugging?: http://groups.google.com/group/android-kernel/search?group=android-kernel&q=kgdb&qt_g=Search+this+group
In particular, you might want to look at this post: http://groups.google.com/group/android-kernel/browse_thread/thread/5233e03391867c98/320beef11e737a62
Here's a few other random links that might be helpful:
http://www.cs.gmu.edu/~astavrou/courses/ISA_673/Android_Debugging/Android_GDB.pdf
http://www.cs.columbia.edu/~nieh/teaching/w4118/ubb/Forum6/HTML/000122.html
http://wiki.ncl.cs.columbia.edu/wiki/AndroidVirt:Guides:Kernel_Debugging
http://source.android.com/porting/debugging_gdb.html
Anyhow, this is an interesting question, and I'm really having a hard time finding anything on it. You might want want to try hopping on IRC sometime (#android-dev or #android-root on freenode) and asking some people there for pointers (please post up what you find here), or maybe asking on the xda-developers Android forums.

Resources