20081028

Android Porting Progress

Hi everyone,

Sorry I haven't posted anything recently, but my days were busy with work, and then my nights were busy porting Android to the FreeRunner. In short, it's coming along, slowly but surely.

I've basically had to teach myself ARM assembly language in the last couple of days (fun, fun, fun!) and thought that I would quickly share all of useful resources that I've come across. So here they are:

The ARM Architecture Reference Manual

This is the definitive reference for pretty much everything. After reading this, I don't think I'll need any other reference material. In fact, I might even print myself a hard copy!

UNSW lab material on microprocessors and embedded systems

This is a surprisingly detailed tutorial for programming ARM in assembly language and C, which sort of bridges the gap between the two languages. It explains precisely the syntax of .S files and complies to the AAPCS (ARM Procedure Call Standard) and Thumb Procedure Call Standard (TPCS). I've archived the material for future reference in case this course website ever goes missing (which tends to happen often with universities).

Finally, the diff that I'm working from

Yes, I realize that it's pretty lame to cling to a single version of Android and not be constantly synchronizing with git and submitting code for review with gerrit, but I have no intentions of targetting anything aside from the FreeRunner / Neo1973 with my port, so I don't really want to deal with the build infrastructure right now. Ignore anything that starts with the less-compatible regular expression '^\- .*smull' (search by hitting '/') - I seem to have hastily deleted those routines in order to get my code to trivially compile before. Please, I don't recommend even trying to apply the diff as a patch - it will do nothing and may even inflict pain on some remote small kitten... and you wouldn't want that, would you? ... But seriously, the diff just highlights what code needs to be worked on. It actually has a lot of 'cruft', i.e. garbage, too, so just look for any lines matching '^\- ' that also contain one of the opcodes listed on the wiki.

Now from what I've been looking at in the code, there are 3 different options for optimizing the .S files for ARMv4T

1) using preprocessor macros for simple opcode translation
2) using globally visible AAPCS-compatible functions for emulating the v5TE instructions (this is where the UNSW tutorial has really come in handy). This is necessary for opcodes that are slightly more complicated, or ones with tricky addressing modes. The GNU preprocessor doesn't really have the capabilities to become a fully fledged scripting language unfortunately.
3) individual, call-by-call changes ... this is the ugly one that I don't really want to touch... but I'm guessing I will have to at some point.

Good luck with your porting efforts!

Chris


Enjoy!

PS: I find black sabbath very useful for putting myself into the 'zone' for programming in ARM assembly.

20081022

Android FreeRunner Updates

Well, I feel as though I've made significant progress in less than one day. I have Android trivially compiling for the ARMv4T / FreeRunner! By saying it compiles 'trivially', i mean that all I've done is remove the ARMv5E instruction extensions and gotten the build process to atually finish without errors. See my post on the android-porting mailing list for further info.

There obviously needs to be a different kernel configuration, but Benno has already done that.

20081021

Hello, Open-Source World!

It's official... Google's brainchild, Android, has finally said
Hello, Open-Source World!

I wonder how many hours it will take for the first Neo 1973 or Neo FreeRunner port to surface. The biggest challenge, it will seem, will be to provide a bridge between the (minimal) ARMv5TE instruction set that Android was designed for, and the OpenMoko handsets' ARMv4T instruction set (as present in the Samsung 2442 SoC).

Perhaps the next handset that OpenMoko releases will feature native ARMv5TE compatibility.

Update: I've been building android for the last few hours, having made a few build-oriented changes that I think will help bridge the ARMv5TE - ARMv4T gap. I'm going to list a few of the errors I've been running into below. Please note - although I only list each undefined instruction once, the errors occur in multiplicity and in different subdirectories. I will post ARMv4T compliant work-arounds soon. Please be patient.

  • bionic/libc/arch-arm/bionic/memcmp.S:44: Error: selected processor does not support `pld [r0,#0]
  • system/core/libpixelflinger/t32cb16blend.S:121: Error: selected processor does not support `smulbb lr,r7,lr'
  • system/core/libpixelflinger/t32cb16blend.S ... Error: selected processor does not support `smulbt ...'
  • external/jpeg/jidctfst.S:148: Error: selected processor does not support `smlabb r0,r2,r3,r5'
  • dalvik/vm/arch/arm/CallEABI.S:239: Error: selected processor does not support `blx ip'
  • dalvik/vm/mterp/out/InterpAsm-armv5.S:2653: Error: selected processor does not support `ldrd r2,[r0,#offStaticField_value]'
  • dalvik/vm/mterp/out/InterpAsm-armv5.S ... Error: selected processor does not support `strd ...'
  • external/sonivox/arm-wt-22k/lib_src/ARM-E_mastergain_gnu.s:77: Error: selected processor does not support `smulwb r4,r4,nGain'
  • external/sonivox/arm-wt-22k/lib_src/ARM-E_voice_gain_gnu.s:114: Error: selected processor does not support `smlawb tmp1,gainLeft,tmp0,tmp1'
  • external/opencore//codecs_v2/audio/aac/dec/src/calc_auto_corr.cpp
    /tmp/ccBi9nUH.s: Assembler messages:
    /tmp/ccBi9nUH.s:652: Error: selected processor does not support `clz r0,ip'
  • smultt, smlatt, smlawt, smulwt, qadd, qsub, qdadd, qdsub, smlabt
  • etc, etc, etc ...
Build problems that were not architecturally related:
  • out/target/product/generic/obj/SHARED_LIBRARIES/libdvm_intermediates/Misc.o: In function `dvmAllocBit': dalvik/vm/Misc.c:247: undefined reference to `ffs'
Theoretically, there are three possibilities to in order to have Android on the FreeRunner.
  • The first is to ] replace [ the red-highlighted mnemonics using an equivalent ARMv4 or ARMv4T instruction sequence. In some cases, this is impossible without a lot of context information.
  • The second is to completely re-implement each section from scratch, wherever one of the ARMv5TE instructions are issued, but using an algorithm optimized for the ARMv4 or ARMv4T architecture
  • The third option is to just remove it, e.g. for the pld instruction which only optimizes memory fetches by hinting (or not?)

20081014

The 2008 Election

It looks as though Canada will again be under a minority conservative regime until we hold our next election. The results of our 2008 election are almost identical to that of 2006 (300 000 000 #$!@#^@!ing dollars later) but with a few notes. Voter turnout was only 59% - the worst in the history of Canada - with only 13832972 of 23401064 registered electors casting a ballot (that does not include unregistered voters). However, I'm happy to see that the Liberals, NDP, Bloc Quebecois, and Green Party managed to prevent a majority conservative government disaster.

It's terribly tragic that Canadians were seduced into voting for the conservative party out of fear for our economic situation - a situation which the conservative party must take a large part of responsibility for. Please let me take this opportunity to apologize to the rest of the world; Canada had her chance to show the world's developing nations how we, the developed nations, deal with environmental issues. By allowing ourselves to continue subjugation to Harper's slippery oil-mafia, we have basically written an environmental cheque that our asses cannot cash.

Green party results by province
ProvinceNumber of Votes%
Alberta1115059
British Columbia1687239
Manitoba317237
New Brunswick226836
Newfoundland32742
Northwest Territories7526
Nova Scotia350228
Nunavut6758
Ontario4114448
Prince Edward Island34885
Quebec1262994
Saskatchewan232796
Yukon188013
Green Votes826747
The size of a metropolitan city...
6%
and we still don't have 1 single seat in the house of commons


I hope that the Harper government acknowledges that poor voter turnout had a huge hand in their minority victory yesterday. There are many Canadians who were unable to make it to the ballot box due to extenuating circumstances - the working class in particular - a huge contrast to Harper's generally upper-class representation. On the other hand, there are probably a lot of Canadians who have such little confidence in our system that they choose not to vote. Some vote because they have not been following the debates.

One thing that was very interesting to observe is that None of the metropolitan cities in Canada (Toronto, Vancouver, Montreal) were won over by the Conservative party. My guess is because we are the ones who primarily have to deal with the smog. People in urban environments are usually have the lesser addiction to oil.

In any event, the Green Party has achieved such an amazing increase in voter turnout from previous years. However, of the ~ 14 million people who voted, ~ 1 million of those voted for the Green Party, yet we still don't have a single seat representing our interests in the House of Commons due to the MP system.

Seriously, we need to reform the way that we vote in this country - why not assign a score to each political candidate instead of voting for a single one? Also, account for "no-shows" and "no-confidence" votes. Mathematically, proportional representation just makes more sense. Account for the loss of power by rural communities by giving rural areas more municipal and regional power, while the interests of the greater public are represented proportionally.

20081006

Linux-2.6.27-rc8 on the EEE 702

Although the Linux kernel version 2.6.27 has not yet been officially released, I was able to download, build and patch release-candidate-8 for my EEE PC with many notable improvements - most notably a working ath5k module. Correction: The Linux kernel version 2.6.27 was released 20081009 and you can read the changes here.

First of all, I was actually planning on using the 2.6.26-gentoo sources, which implemented the changes upstream that I had made for the 2.6.24-eee-r1 sources, because it already had the eeepc-laptop module sources included, and (limited) ath5k support.

However, when I tried to 'modprobe ath5k' with the 2.6.26-gentoo kernel, I encountered a nasty error message saying that the AR2425 chip is still under development (boo-urns!), and that support for the AR2425 chip would be included in the 2.6.27 sources. That made me revert back to my 2.6.24-eee-r1 linux kernel, but not for long!

Having never been the type to accept defeat so easily, I decided to use the vanilla-sources-2.6.27-rc8. The main difference between the vanilla and Gentoo sources are, that the Gentoo kernel sources (and subsequently the eee sources) are patched versions of the vanilla kernel, which include security fixes as well as various other features (SquashFS for example).

Now, I do need SquashFS for my squashed portage, but the security patches I could do without for the time being, until Kernel.org, and Gentoo, release their respective 2.6.27 kernel sources. Aside from that, I would need to compile external modules for the EEE pc, such as uvcvideo (webcam), eeepc-linux (Fan / CPU / FSB control).

Thanks to the inclusion of the eeepc-laptop sources, providing ACPI interfaces for all of the EEE PC Fn buttons, I could now omit the external asus-acpi module, as well as the quasi-proprietary ath_hal module provided with net-wireless/madwifi-ng.

Yes, that's right! Now the Atheros chipset on the EEE PC will work with the standard 'wext' wireless interface, allowing the unpatched version of NetworkManager to run seamlessly!!! Although I have switched to WICD since the last time I tried to use NetworkManager, but I thought I'd mention the changes anyway.

Here are a few patches that might be of interest:
eeepc-linux-2.6.27-rc8.patch
linux-2.6.27-rc8-squashfs3.4.patch
atl2-2.6.27-rc8.patch

All of these will work with sys-kernel/vanilla-sources-2.6.27_rc8.

Enjoy!