Ever since I owned my HD2, I wanted to hack it and try and get Linux on it. Just like I helped to get it started on the Raphael, even though I had to drop out early due to lack of time unfortunately. I tried to uphold my famous way of debugging using the flashlight led at the back of the device. Like, boot the linux kernel, and when the led goes on, I know it reached that specific code. Then I can recompile and see if I get any further. It's poor mans debugging, but I love it. I sorted out some of the code to do this and put it on the appropriate wiki page.
HaRET bootloader
Before being able to continue at all, the bootloader had to be updated with support for the QSD8x50 SoC. Luckily a patch for u-boot was already present at codeaurora which adds support for the QSD8x50, so that could be used. Also, the core of the QSD8x50 is a Cortex-A8, which is partially documented on the ARM website here. The patches I applied to HaRET can be found at the HaRET git repository.
QSD8x50 support in codeaurora git tree
After fixing HaRET I tried to use the kernel in the codeaurora git tree, but it didn't really cooperate that well. At first all attempts failed. I compiled a kernel and couldn't even get into the very first instruction which is executed by the kernel. The only thing before the entry point of the kernel, is the decompression routine which is prepended to zImage images. And there I won a price, as the using the uncompressed Image did execute my famous flashled code. The flashled turned on which indicated it got to the code in the kernel. After quite a while of searching and playing, I found that there is an instruction which is not ARMv7 compatible: "mcr p15, 0, r10, c7, c14, 0". It should be a perfectly sane operation (to clean and invalidate the D-cache on Cortex-A8 processors), but causes an invalid instruction exception on the processor in my HD2. After fixing this to ", 2" at the end (which isn't entirely the same, but gets the job done), the decompression routine worked as well.
The next problem was that the kernel didn't boot up to iomapping. Something went wrong before that. This is however a problem for my poor mans debugging. As soon as the MMU (memory mapping unit) is enabled, I cannot access the physical memory addresses to switch on my flashled. I have to wait until after the iomapping is done before I can use the virtual address to access the hardware for the led again. As it hang between these things, I tried really a lot of things (without going too deep, i.e. I still don't know how to iomap() phsyical => virtual memory using assembly) but eventually decided to wait until a better kernel tree was available for the QSD8x50.
Patching the Nexus One kernel
And soon after that, the Nexus One was announced by Google and its kernel was made available. Without making a really long story again like above, I had to patch a few things to get this to work:
For now, this is where I'm at! Awesome, right?
To other developers! Don't worry, a git repository will be setup soon. When there's more info about that, I'll put it here too.
HaRET bootloader
Before being able to continue at all, the bootloader had to be updated with support for the QSD8x50 SoC. Luckily a patch for u-boot was already present at codeaurora which adds support for the QSD8x50, so that could be used. Also, the core of the QSD8x50 is a Cortex-A8, which is partially documented on the ARM website here. The patches I applied to HaRET can be found at the HaRET git repository.
QSD8x50 support in codeaurora git tree
After fixing HaRET I tried to use the kernel in the codeaurora git tree, but it didn't really cooperate that well. At first all attempts failed. I compiled a kernel and couldn't even get into the very first instruction which is executed by the kernel. The only thing before the entry point of the kernel, is the decompression routine which is prepended to zImage images. And there I won a price, as the using the uncompressed Image did execute my famous flashled code. The flashled turned on which indicated it got to the code in the kernel. After quite a while of searching and playing, I found that there is an instruction which is not ARMv7 compatible: "mcr p15, 0, r10, c7, c14, 0". It should be a perfectly sane operation (to clean and invalidate the D-cache on Cortex-A8 processors), but causes an invalid instruction exception on the processor in my HD2. After fixing this to ", 2" at the end (which isn't entirely the same, but gets the job done), the decompression routine worked as well.
The next problem was that the kernel didn't boot up to iomapping. Something went wrong before that. This is however a problem for my poor mans debugging. As soon as the MMU (memory mapping unit) is enabled, I cannot access the physical memory addresses to switch on my flashled. I have to wait until after the iomapping is done before I can use the virtual address to access the hardware for the led again. As it hang between these things, I tried really a lot of things (without going too deep, i.e. I still don't know how to iomap() phsyical => virtual memory using assembly) but eventually decided to wait until a better kernel tree was available for the QSD8x50.
Patching the Nexus One kernel
And soon after that, the Nexus One was announced by Google and its kernel was made available. Without making a really long story again like above, I had to patch a few things to get this to work:
- irq.c was patched to not enable the INT_DEBUG_TIMER_EXP (enabling this interrupt causes the device to hang)
- timer.c was modified not to use this timer (the first mdelay() called would hang the device as the interrupt gets enabled)
- board-mahimahi.c was used for testing purposes, stripped it from most drivers and init code and replaced it (the mahimahi = Nexus One)
- io.c and msm_iomap.h were modified to make MDP available for htc_fb_console (which I borrowed and modified from the Raphael linux project)
- htc_fb_console was added and modified to work on the HD2
For now, this is where I'm at! Awesome, right?
To other developers! Don't worry, a git repository will be setup soon. When there's more info about that, I'll put it here too.
amazing work - keep going ( terminal7 uk )
ReplyDeleteYou are the first developer with real progress on that android thing for hd2! Don't stop your work, move on and ask for help if you need!
ReplyDeleteGreetings from Germany,
Sebastian
yesss...
ReplyDeletethis means androïd on HD2 is on the way
i don't know anything in dev but if you need a tester, send me a e-mail at willbread@gmail.com
thanks from France
Hi ;-)
ReplyDeleteGreat work ...
Can you give us your boot script of haret ? Witch values you used as display, memory, etc ?
Greetings from France (again a french man ;))
Don't hesitate, ask for help if you need some !
The script I'm using is:
ReplyDeleteset mtype 2304
set ramaddr 0x20000000
set ramsize 0x0e000000
set kernel Image
set initrd ""
set cmdline "init=/init root=/dev/ram mem=32M"
Note that mtype 2304 makes it boot the mahimahi board, which is the Nexus One. This is the board file I've been playing in. When the git is up, HD2 will get its own mtype. Also note Image instead of zImage. I feel more confident with that one ;)
Nice job :)
ReplyDeleteDon't hesitate to ask some help if needed (XDA post for instance or this place).
Hey Martijn Stolk ;)
ReplyDeleteWhere did you get your kernel sources from ?
Are you compiling from that ? http://android.git.kernel.org/?p=kernel/msm.git;a=shortlog;h=refs/heads/android-msm-2.6.29-nexusone
Thanks for your reply ... :)
Yep, the nexusone head. It's linked in the article.
ReplyDeleteNice. Sorry, tired eyes x-x
ReplyDeleteHave you modified something into sources, or did you compile original files ?
That's also in the article. Not the exact changes, but an overview of what I did. You should really read...
ReplyDeleteYeah I saw that.
ReplyDeleteBut I'd like to say nothing _else_ ?
So what prevent GUI to run ?
I'm a nood in Android, never seen it working... Is the GUI based on a X server ?
This is just the beginning. All kinds of hardware support needs to be added to the kernel, before even thinking about running Android. Android won't run on it anytime soon. People specifically waiting to use this phone with Android on it, should expect 6-12 months before it fully works. Depends on the amount of effort put into it by various people.
ReplyDeleteSo, many thanks for your work !
ReplyDeleteI believed Leo has same hardware as Nexus, expect the screen ... If everything's different ... :-(
Finally it's too hard for me. I've learnt many things, but what I'm supposed to do to get Android running is over my courage.
You should post it on XDA. There are many people wanting Android to run tomorrow on their phone. It seems to be a cold shower for them.
:-p
@Martijn
ReplyDeleteDo you really think drivers are a big problem? How different are HD2 and NexusOne? I can't imagine that HTC has chosen to build to devices on the same platform with totally different chips on it.
Sebastian
Hi Sebastian,
ReplyDeleteThere are similarities between the Nexus One and the HD2. That means some drivers be re-used. The compass, the framebuffer driver, usb and sdcard. Maybe even more, but will find out along the way.
Things that are different from the Nexus One include at least the gsm (call handling), audio, umts/gprs data, vibrator motor, bluetooth and anything else that is handled by the radio rom. We could probably use parts of the code from Raphael (touch pro) to help here.
In conclusion, some things can be reused from the Nexus One, some things can be reused from the Raphael (and alike) and some things will need to be done from scratch. However, anything that can be re-used, must probably be reconfigured for a different memory layout as well. It's not just 1-on-1 copy. Can't give you a 'number' of how big the problems are. :)
NetRipper,
ReplyDeleteIs the idea of making a git for your development in your mind ?
If yes, do you need some help (money, webserver, ...) ?
I've tried to compile image, making same things as you described in the article ... In can't run what you succeeded to :-(
You're the best, for sure ;)
Greetings.
@martijn
ReplyDeleteOkay, I think understand the problem. I really thougt it would be easier, because I had no knowledge about the radio rom thing... so no 1:1 copy on n1 to hd2 :-(
But we will support your efforts to make android running on our hd2's!
Ask for help, if you need!
@netripper
ReplyDeleteThx for your answer!
I've a new, maybe stupid question :-)
You said, we have to develop the complete radio rom part (drivers etc.). If an android device has the same hardware, wouldn't it be possible to take its radio rom?
Sebastian
Amaziingg work!!! Thanks, This is just what I was looking for. I hope you can port android to the HD2 succesfully. I'm serious, I realy appreciate your work.
ReplyDeleteKeep Up the great work man!!!!!!!! You are an amazing developer.
ReplyDelete