How to view bootchart of an embedded device such as smartphone? - view

I have a laptop installed windows 7 x64 and a virtual machine with Ubuntu 12.04. I installed Bootchart on my virtual machine. I can view bootchart diagram of my virtual machine after log it on.
But I wonder... Is there any way to view bootchart diagram of an embedded device such as my android smartphone if i connect it to my laptop?
Can you help me to solve this? Thank you very much.

If you are a developer with the Android source code, you can use the following method and the bottom link to enable the bootchart on you smartphone.
brief instruction is like:
install the bootchart tool on your host machine
build 'init' with bootchart support
install 'init' into your system image
trigger bootchart functionality on system boot
retrieve the collected data from the system
generate the graphic from the data
view the resulting graphic
interpret the results
and more details please refer to :
http://elinux.org/Using_Bootchart_on_Android

dmesg command will be the one of the most helpful tool in providing log messages right from beginning of booting as far as any operating system based on linux. It prints the message buffer of kernel and it should also enable you to decode the boot sequence. You can also redirect the kernel messages using the 'console' command via the interface(UART / USB) that is available on the device.
Another interesting tool that could work in tandem with dmesg is netconsole if the device does not provision for other interface based logging or issues in disk logging. It sends all kernel log messages without any dependency on userspace, to another computer over the network (UDP) . However note that netconsole initializes only after NIC card initialization and hence capture of early kernel logs before this point will not be there but captures the rest of the boot process.

Related

Can USB-OTG be used for U-Boot and Linux consoles?

I have a custom i.MX6Q-based board with working U-Boot and Linux (Ubuntu) setups. The micro and board have support for USB-OTG and one serial port; currently, the serial port serves the console for both U-Boot and Linux. However, we may need to use the serial port for another purpose, but we don't want to lose the console for U-Boot and Linux. Is it possible to use the USB-OTG port for the system console for both U-Boot and Linux?
I've done some research and found a couple of promising articles here and here, though the second article says this tidbit:
Unfortunately it won't work as system console as the gadget driver is loaded as a module, but we can use it for serial console.
I'm not sure I understand this, but it sounds like the method won't meet my needs, which is to use USB-OTG for both U-Boot and Linux system consoles. I did try these methods, but without luck, which may mean that U-Boot and Linux aren't built properly for the desired functionality.
So here are my questions:
Can this work for U-Boot?
Can this work for Linux?
Am I insane for contemplating this path?
For either, any guidance (e.g. tutorials, examples, etc.) would be greatly appreciated.
Thanks!
Can this work for U-Boot?
Yes, at least since U-Boot version 2008.10, the README file has stated:
Define the below if you wish to use the USB console.
CONFIG_USB_DEVICE
Define this to build a UDC device
CONFIG_USB_TTY
Define this to have a tty type of device available to
talk to the UDC device
CFG_CONSOLE_IS_IN_ENV
Define this if you want stdin, stdout &/or stderr to
be set to usbtty.
Note that these configuration symbols are not accessible using the menuconfig, and must be enabled in a configuration file.
Currently at least five boards use this U-Boot capability, based on the occurrence of CONFIG_USB_TTY in files in include/configs/, for example include/configs/ti_omap4_common.h.
This USB configuration requires non-default definitions for the stdin and stdout environment variables. Refer to the README documentation for the details.
Can this work for Linux?
Yes, Linux (at least since version 4.5) can have a serial console on a USB connection, either a USB-to-serial adapter on a host port or a USB serial gadget on a device port (using CDC/ACM).
For instance, in drivers/usb/gadget/Kconfig there's the selection:
config U_SERIAL_CONSOLE
bool "Serial gadget console support"
depends on USB_G_SERIAL
help
It supports the serial gadget can be used as a console.
In the Linux 5.7.8 kernel only two boards have default configurations that use this capability, for example see arch/arm/configs/aspeed_g4_defconfig.
Besides a proper configuration to build the necessary drivers, a serial-gadget console requires (1) the kernel parameter specification (e.g. console=ttyGS0,...), and (2) a login session initiated by a getty command (e.g. in the inittab file).
Am I insane for contemplating this path?
No comment.
Beware that should you encounter a kernel boot issue, the Linux serial-gadget console does not support earlycon nor earlyprintk capability.
Personally I prefer to use a serial link that is persistent regardless of the target board's state. That ensures the terminal emulator program does not complain about lost connections.
Addendum
Unfortunately this Linux console on a USB serial gadget does not display boot messages generated by the kernel (before the login prompt), even if all drivers are statically linked in to the kernel image.
Although the syslog has messages like
console [ttyGS0] enabled
g_serial gadget: g_serial ready
...
gs_open: ttyGS0 ((ptrval),(ptrval))
before the salient Freeing unused kernel memory message, the host side does not receive any console messages until userspace is active.
This shortcoming is also reported in this guide: https://linux-sunxi.org/USB_Gadget/Serial

Can a Kernel Mode Driver Prevent a Windows System from Booting?

I have recently been attempting to create a GPIO Driver for SBC's using an Intel chipset that run Windows 8.1 and have begun testing it on an actual system. After loading the Driver and updating the Intel chipset I am using, the system appears to hang after loading the BIOS. Unfortunately, this disables my mouse, keyboard, and video, preventing me from entering BIOS or the boot manager.
While it is possible that the chipset update caused the system to become unbootable, it is highly unlikely considering we use that update for our other SBC's running the same chipset.
So my question: Is it possible for a Windows Kernel Mode driver to prevent a system from booting up past BIOS/POST?
I appreciate the help, since, clearly, I am no expert on this topic.
Yes, if your driver is being loaded at boot time it can prevent the booting of the OS and it will end up in BSOD(Blue screen of death) error with related bug check.
According to bugcheck displayed by the OS you can resolve the issues with your driver.
Or sometimes if its not giving any error and just hangs you can use WinDbg to check the bugcheck.
It depends on the error control of the driver service. Boot time drivers can also fail at any point. There is nothing special about the failure happening during boot. Instead, what is relevant under this scenario depends more on the ErrorControl value of the driver service which specifies how to proceed if it fails to load or initialize properly. A value of 3 (critical) would reboot the system to LKGC. Same rules apply to a win32 servic as well..

controlling hub power from linux shell

I am using a buildroot image (3.12 kernel) running on my raspberry Pi with a USB LED light connected to it and I want to control on/off through the CLI.
I went through this. However, there is no control or level file in the power folder.
Is there any kernel configuration that I have to enable to get this ?
Found the answer to this. I have to enable PM_SUSPEND in the kernel configuration to get the class files. But then, as mentioned in the comments, RaspberryPi has the power lines directly connected to the power rails

Issue with qemu and gdb

I have a device driver that is freezing the OS. The mouse wont even move. I am trying to debug this issue and I believe one good approach is to use gdb with qemu, two things I have never used before. Is there a better approach?
So first I need to compile the kernel with debug symbols which I have done already.
Now, there is a new file that is generated called vmlinux that is located in that same folder as the source. It seems that I also need a bzImage file according to this so I can run the newly compiled kernel using:
qemu-system-i386 -kernel bzImage
or in debug mode
qemu-system-i386 -s -S -kernel bzImage
I cannot locate the bzImage file. Where do I find it or what is missing here? Is the bzImage referring to the OS Image I created using qemu-img create?
Also, what I do not understand is that now the kernel is compiled (vmlinux) how does I run it with qemu? So my question is when I run it with qemu or the debugger is the kernel running as an app in my main OS?
also how can I install my device driver? My understanding the kernel is not Ubuntu so there is no UI?
Also, I installed qemu and when I type qemu I get command not found. I am guessing I have to pick a specific processor emulator as in qemu-system-i386, qemu-system-x86_64, or qemu-x86_64?
How is qemu different or similar to the kvm command?
Thanks.
So, if I understand the problem correctly, you have a kernel module that needs no specific hardware. When you are working with the module, the system freezes but the kernel log contains nothing special.
The following may be helpful.
Getting the log
The symptoms you described may still be a result of a kernel oops or panic. The logging facilities sometimes die before they can output the information about the error to the log file. You may try to output the log via a serial port, this should be more reliable.
As your kernel module does not need any specific hardware, the easiest way is probably to install the same Linux distro as you use to a virtual machine and connect the virtual serial port (COM) of that machine to a pipe on your host system.
This is usually quite easy to do. For example, this blog post contains the detailed instructions in case the host OS and the guest OS are Ubuntu 11.10.
VirtualBox is used there to manage the virtual machines. If you prefer QEMU, this should be possible as well. I suppose it is a bit easier to go with VirtualBox though but it is a matter of personal preference.
Basically, you need to perform the following steps.
Create a virtual machine and install the Linux distro you need as a guest OS there.
Enable a serial port (COM1, ...) in the configuration of the virtual machine and configure it to connect to a special file on the host ("host pipe"), say /tmp/vbox_serial.
Start the guest OS and adjust its boot options: at least, add console=ttyS0,115200 or something like that to the kernel options in the boot loader menu.
On the host, start minicom, socat or whatever else to read from /tmp/vbox_serial.
That is it. Now you should get the kernel log of the guest OS pouring to your host system via /tmp/vbox_serial. If the guest system crashes then, you will get the log even if it is not saved into a file on the guest itself.
To make things easier, you may use socat on your host system rather than minicom that the author of that blog post suggests. The power of minicom is probably not needed here.
This way, you can use socat and tee to save the log to guest.log file while still outputting it to the console:
socat /tmp/vbox_serial - | tee guest.log
If there was a kernel oops or panic, the backtrace in the log usually helps to find out what
has gone wrong.
Detecting Deadlocks
If you have obtained the full log via a serial connection or some other means and still there is nothing suspicious there and you suspect there has been a deadlock in the kernel,
lockdep tool may help. It is included into the kernel (but you may need to rebuild the kernel with CONFIG_LOCKDEP_SUPPORT=y).
Lockdep detects the potential deadlocks and outputs the results to the kernel log. This presentation may help you analyse its output.
Tracing Facilities
If you need tracing of some events in the kernel to debug your system, there are some tools that could be handy.
Kprobes - a kind of breakpoints you can set in almost arbitrary place in the kernel. Can be used to trace function calls among other things, with a moderate performance impact.
SystemTap - a powerful system to analyze what is going on in the kernel. Part of it is based on Kprobes.
Ftrace - a tracing system included into the kernel, incurs less overhead than Kprobes if that matters.

How do I get to see DbgPrint output from my kernel-mode driver?

I'm finding it difficult to see the debug output from a kernel-mode driver I'm working on.
I'm new to driver development. I'm trying to debug a USB driver on Windows XP. I've installed the DDK, and built a "checked mode" build of my driver. I've installed the driver and if I use a hex editor to look at my driver's .sys file in windows/drivers, I can see the text of my debug output strings.
If I run an app that uses my driver under Visual Studio, my debug output doesn't appear in the output window, as the application's own debug output does. Searching the web, I find many different claims about how one is supposed to display debug output from the kernel. For kernel debugging in general, people seem to either do remote debugging over a NULL modem cable (Crikey, it's 2012) or use a virtual machine and a virtual com port. Both these approaches seem like a massive amount of work just to be able to see debug output. Is there an alternative?
I've tried using WinDbg in "Local" kernel debugging mode but it doesn't show anything. It warned that I should reboot windows with "/debug" enabled. I did that, but it didn't help.
Any other ideas? Or am I asking for the impossible?
DebugView will show you the trace messages from your driver:
http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
However, you really do need a two machine setup to do any real development work.
The information you found is correct. You do need 2 machines to debug kernel-mode drivers.
If you choose to use 2 physical machines they can be connected via USB. NULL modem (COM port) is a common way to attach debugger to a virtual machine where VM's COM port is seen as a named pipe on the host, so you don't really need a NULL modem cable.
Couple of links
http://msdn.microsoft.com/en-us/library/ff538141.aspx
http://msdn.microsoft.com/en-us/library/ff542279.aspx

Resources