QSD8250 illegal instruction on WinCE devices
Subsystems (2)
Hi,
With the acer s200 we now have a second WinCE based device supported by our kernel for htc leo atgit://git.linuxtogo.org/home/groups/mobile-linux/kernel.git
htc-msm-2.6.32 . S200 has 256MB ram rather than 512 in leo. Only a small patch to rearrange memory mapping was needed.
The same cpu crashes as on leo were observed when booting an openembedded initrd on s200. So I think we can conclude that the illegal instruction problem is not specific to the very leo hardware.
Please look at the following prints on snapdragon SoC:
acer s200:
QUALCOMM(R)
QSD8250
BK153.R1
H192600C
AAB
htc leo:
QUALCOMM(R)
QSD8250
B0US19.0
H192500C
AAB
passion aka nexus one:
QUALCOMM(R)
QSD8250
B1F777.0
H194400C
This is taken from FCC testing photographs. More at
http://htc-linux.org/wiki/index.php?title=Qsd8250 Not the acer s100 (also wince device) with AAA suffix.
I think it is striking that the nexus one which comes with linux installed lacks the three letter suffix.
S200 and leo come with WinCE so it's obvious both have WinCE AMSS version. Both have the AAB appended on the SoC print. Both devices show the cpu crash (as indicated earlier the kernel used on both devices is almost same. so it's up to you how valid this is)
Nexus one aka passion comes with linux and has a linux specific AMSS version. All kinds of binaries with instruction sets spoken by cortex-a8 can be executed without any crashes.
It seems obvious that the problem is in some way related to the fact that our system is designed for use with WinCE.
(On a side note WinCE makes limited use of the optimizations of different ARM versions afaik. Yes, we did try running userspace without them. E.g. I tried to use a debian armel rootfilesystem with armv4t which works well on the nexus one / passion but it failed for me)
As it was mentioned it might be that the SoC in leo device is 'programmed' in a different way because WinCE assumes different things than linux. I can confirm this to a certain extent. It is known that there are massive differences in the AMSS. E.g. we need to patch proc_comm, clock, ... for use with WinCE amss devices. But as I stated earlier we never had such a problem with crashes on the older WinCE devices with msm7x0x non-A and msm7xxxA. When linux boots you can execute everything. This is a phenomenon limited to WinCE qsd8.
A different thing to keep in mind is that we do not have a clean boot. Before WinCE is removed from memory and the linux kernel is loaded and started quite some stuff happens to the hardware. How far could this be related?
I am wondering about the qsd8 devices you QIC Inc. guys are working with. What about the snapdragon fish? Do they have the three letter suffix on qsd8250 ? Are there extra evaluation baords for WinCE ?
Once I received my 3,3V ttl level UART device I will try to bootgit://codeaurora.org/quic/kernel/dwalker/linux-msm.git msm-core kernel on leo. As I'm not the best coder I'm wondering if it is good to help for ask here regarding leo specific patches in that branch.
Thanks
Lukas
Hello,
The segmentation fault problem on htcleo and other WinCE based qs8250 devices is solved. We need to set the cpu into some magic mode before boot and all cpu crashes are gone.
As suspected it is in fact in some way related to WinCE VS. linux device: A WinCE developer with low level knowledge by the name of K, 'Cotulla' Ivan looked at the bootloader of qsd8250 based htc bravo, one of the _linux_ phones with the chip. This is where the necessary cpu init code was discovered. This init code is obviously not needed and used for WinCE which is why we were in 'crash mode' when booting linux. It is suppoed to be some workaround for a 'hardware bug'.
The HaRET Handheld Reverse Engineering Tool and bootloader was patched by Martijn Stolk with the qsd8250 cpu init code. Using this patched version we successfully tested htc leo / hd2 and acer s200 using our htc-msm-2.6.32 kernel. No segmentation faults or illegal instruction errors were observed on either device.
I am attaching the initial init file with the fix and the HaRET patch that was derived from it. The original mailing list thread is archived at
http://lists.linuxtogo.org/pipermail/mobile-linux-discuss/2010-June/000128.html
I am really wondering if qsd8* evaluation boards use something similar..
Regarding thoughts about different SoC revisions it seems like the B in qsd8250B devices is not relevant.
Thanks again for the help with this !
Lukas
Makefile +2 -2
@@ -34,7 +34,7 @@ endif .PHONY : all FORCE vpath %.cpp src src/wince src/mach -vpath %.S src src/wince +vpath %.S src src/wince src/mach vpath %.rc src/wince ################ cegcc settings
@@ -108,7 +108,7 @@ $(OUT)mach-autogen.o: src/mach/machlist.txt COREOBJS := $(MACHOBJS) haret-res.o libcfunc.o \ script.o memory.o video.o asmstuff.o lateload.o output.o cpu.o \ linboot.o fbwrite.o font_mini_4x6.o winvectors.o exceptions.o \ - asmstuff-armv5.o + asmstuff-armv5.o bootQSD8xxx.o HARETOBJS := $(COREOBJS) haret.o gpio.o uart.o wincmds.o \ watch.o irqchain.o irq.o pxatrace.o mmumerge.o l1trace.o arminsns.o \
src/bootQSD8xxx.S new file +311 -0
311 lines not on this page · raw message
src/linboot.cpp +9 -1
@@ -147,7 +147,7 @@ setup_linux_params(char *tagaddr, uint32 phys_initrd_addr, uint32 initrd_size) ****************************************************************/ // Maximum number of index pages. -#define MAX_INDEX 6 +#define MAX_INDEX 10 #define PAGES_PER_INDEX (PAGE_SIZE / sizeof(uint32)) // Data Shared between normal haret code and C preload code.
@@ -251,6 +251,10 @@ fbOverlaps(struct preloadData *pd) , pd->initrdOffset + pd->initrdSize); } +extern "C" { + void bootQSD8xxx(char* kernel, uint32 mach, char *tags); +} + // Code to launch kernel. static void __preload preloader(struct preloadData *data)
@@ -324,6 +328,10 @@ preloader(struct preloadData *data) FB_PRINTF(&data->fbi, "Jumping to Kernel...\\n"); + // QSD8xxx hack to boot kernel without segfaults + bootQSD8xxx(destKernel, data->machtype, destTags); + FB_PRINTF(&data->fbi, "Shouldn't get here\\n"); + // Boot typedef void (*lin_t)(uint32 zero, uint32 mach, char *tags); lin_t startfunc = (lin_t)destKernel;
Quoted 5 lines · Lukas-David Gorris
Hello,
The segmentation fault problem on htcleo and other WinCE based qs8250 devices is solved. We need to set the cpu into some magic mode before boot and all cpu crashes are gone.
Great! I'm glad that someone figure it out.
Quoted 7 lines
As suspected it is in fact in some way related to WinCE VS. linux
device: A WinCE developer with low level knowledge by the name of K, 'Cotulla' Ivan looked at the bootloader of qsd8250 based htc bravo, one of the _linux_ phones with the chip. This is where the necessary cpu init code was discovered. This init code is obviously not needed and used for WinCE which is why we were in 'crash mode' when booting linux. It is suppoed to be some workaround for a 'hardware bug'.
Was a specific instruction discovered that fix it? The files and patches that you provided include a fair amount of code.
Daniel
Quoted 6 lines · Daniel Walker
Was a specific instruction discovered that fix it? The files and patches that you provided include a fair amount of code.
Daniel
We still have to isolate which part of that asm specifically solves the problem, as it includes quite a lot of initialization code indeed. For now we're just glad we can continue our quest of getting Linux to run on our phones. :-)
I'll try and isolate the problem area soonish and post it here.
Regards,
Martijn
Quoted 7 lines · Martijn Stolk
Quoted 6 lines · Daniel Walker
Was a specific instruction discovered that fix it? The files and patches that you provided include a fair amount of code.
Daniel
Quoted 6 lines
We still have to isolate which part of that asm specifically solves the problem, as it includes quite a lot of initialization code indeed. For now we're just glad we can continue our quest of getting Linux to run on our phones. :-)
I'll try and isolate the problem area soonish and post it here.
Don't do it on my account, I was just wondering if that was discovered..
Daniel
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
No worries. I wanted to isolate what specifically fixes the problem myself in order to make a minimal patch. I'm also hoping for some help regarding information, as I don't have access to official QSD8250 documentation.
I've found the key register that differs between between how it is initialized for Windows CE and for Linux, and solves the problem for us. It is the Auxilliary Control Register (cp15, 0, c1, c0, 1).
For Windows CE it is initialized to 0x002C0077 (=0b00000000001011000000000001110111)
For Linux it is initialized to 0x000C0037 (=0b00000000000011000000000000110111)
The following page explains this register for the Cortex-A8, the ARM core on which the QSD8250 is based:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344k/Bgbffjhh.html
The 7th bit (bit 6 on that page) controls the behaviour of the Invalidate All & by MVA instructions. It needs to be disabled for Linux.
The 22nd bit, however, is in an area marked as "reserved" on that page. I am very curious what this bit does. Maybe this reserved area is documented in QSD8250 documentation? Could anyone provide clearity about this bit?
In conclusion, we are able to continue our work using the following asm, but do not know what the second flag means:
MRC p15, 0, r0, c1, c0, 1
BIC r0, #0x40
BIC r0, #0x200000
MCR p15, 0, r0, c1, c0, 1
Thanks in advance for any information.
Regards,
Martijn
Quoted 5 lines · Daniel Walker
Don't do it on my account, I was just wondering if that was discovered..
Daniel
Quoted 18 lines · Martijn Stolk
No worries. I wanted to isolate what specifically fixes the problem myself in order to make a minimal patch. I'm also hoping for some help regarding information, as I don't have access to official QSD8250 documentation.
I've found the key register that differs between between how it is initialized for Windows CE and for Linux, and solves the problem for us. It is the Auxilliary Control Register (cp15, 0, c1, c0, 1).
For Windows CE it is initialized to
0x002C0077
(=0b00000000001011000000000001110111)
For Linux it is initialized to0x000C0037
(=0b00000000000011000000000000110111)The following page explains this register for the Cortex-A8, the ARM core on which the QSD8250 is based:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344k/Bgbffjhh.html
Quoted 7 lines
The 7th bit (bit 6 on that page) controls the behaviour of the Invalidate All & by MVA instructions. It needs to be disabled for Linux.
The 22nd bit, however, is in an area marked as "reserved" on that page. I am very curious what this bit does. Maybe this reserved area is documented in QSD8250 documentation? Could anyone provide clearity about this bit?
You found that you needed both of these set? One or the other wasn't enough.
I'm not sure that we can open talk about what this 22nd bit does, so I'd just set it like you have it and not worry about it.
Daniel
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Quoted 27 lines · Daniel Walker
Quoted 18 lines · Martijn Stolk
No worries. I wanted to isolate what specifically fixes the problem myself in order to make a minimal patch. I'm also hoping for some help regarding information, as I don't have access to official QSD8250 documentation.
I've found the key register that differs between between how it is initialized for Windows CE and for Linux, and solves the problem for us. It is the Auxilliary Control Register (cp15, 0, c1, c0, 1).
For Windows CE it is initialized to
0x002C0077
(=0b00000000001011000000000001110111)
For Linux it is initialized to0x000C0037
(=0b00000000000011000000000000110111)The following page explains this register for the Cortex-A8, the ARM core on which the QSD8250 is based:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344k/Bgbffjhh.htmlQuoted 7 lines
The 7th bit (bit 6 on that page) controls the behaviour of the Invalidate All& by MVA instructions. It needs to be disabled for Linux.
The 22nd bit, however, is in an area marked as "reserved" on that page. I am very curious what this bit does. Maybe this reserved area is documented in QSD8250 documentation? Could anyone provide clearity about this bit?
Quoted 8 lines
You found that you needed both of these set? One or the other wasn't enough.
I'm not sure that we can open talk about what this 22nd bit does, so I'd just set it like you have it and not worry about it.
Daniel
Here's a table on what I noticed during my tests:
bit: 7 | 22 | remark
1 | 1 | Linux crashes due to segmentation faults
0 | 1 | Linux works fine, no crashes, no segfaults
0 | 0 | Same as above
1 | 0 | Linux doesn't segfault immediately, but seems to only cause problems
when the device is idling for a second or less (maybe
power management
or something).
Disabling bit 7 solves the segfault issues already. Bit 22 just causes some mysterious behaviour which I am curious about. We're able to continue without knowing this of course, but I was hoping you were allowed to answer a specific question like this. Don't worry if you can't.
Thanks either way for your help.
Regards,
Martijn