How To: Build Garmin-Asus Kernel from Source
Tuesday, May 17, 2011 8:05 AM
Posted by kthksdie
So, here's a short how to for compiling the source code provided by Garmin-asus. Please note there may be a step or two missing. I'll be updating this later when I get a chance to start from scratch and compile a better How To.
The originial directions for porting a kernel can be found here: http://wiki.cyanogenmod.com/index.php?title=Howto:_Build_a_Kernel_Port
1. Download the v.5.0.70 kernel source from garmin-asus.
Which can be found here: http://www.garminasus.com/developer/
2.
# curl http://android.git.kernel.org/repo >~/bin/repo3. Copy the kernel folder from Garminfone_T-Mobile_5.0.70.tar.gz.
# chmod a+x ~/bin/repo
# mkdir <Android source dir> && cd <Android source dir>
# repo init -u git://github.com/CyanogenMod/android.git -b froyo
# repo sync
# export PATH=$PATH:~/<Android source dir>/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin
4. Place it in <Android source dir>
5. Rename it, 'asus-kernel'
6.
# export ARCH=arm7. Download my ERE27.zip found in my post: http://mygarminfone.blogspot.com/2011/05/rom-dump-for-garminfone-a50-21-update1.html.
# export CROSS_COMPILE=arm-eabi-
# export KERNEL_DIR=/full/path/to/asus-kernel
8. Extract asus_defconfig
9. Place asus_defconfig in <Android source dir>/asus-kernel/arch/arm/configs
10.
# cd <asus-kernel source dir>It should work, I pulled what I did from memory. So like I said, if you're having issues, give me some time to get together a better How To.
# make asus_defconfig
This entry was posted on 8:05 AM, and is filed under
. Follow any responses to this post through RSS. You can leave a response, or trackback from your own site.
Subscribe to:
Post Comments (Atom)
May 17, 2011 at 11:04 AM
There's also source code for various versions all packed into a 600MB file called A50_OpenSourceCode.zip at:
http://www.asus.com/Mobile/A50/#download
It includes source for some of the on-device tools as well as just the kernel. However, the zip file seems to be corrupted so only some of the versions work. One of the working ones is from March, and I believe it may contain some bugfixes.
May 17, 2011 at 11:07 AM
These are exactly the instructions I needed to keep going on the work I'm doing.
Here's some more info, in case you need it :)
The .update file for ROM updates is an ext3 image. When you mount it with the loop driver you get some files, including a .raw file. This is standard layout, apparently used in a lot of MSM phones. Someone wrote a python script that extracts all of the parts... including radio firmware, primary and secondary boots, lots of things that can brick your phone if you play with them.
The fun part is that it gives you the recovery.img and system.img... the recovery image is yaffs2 with a kernel and cpio recovery partition, and the system image is ext3... so you can take an update from another language or related phone (A10) and extract files from them... may be useful.
The boot and recovery images use different loader addresses and kernel boot parameters, so the standard unpack and repack scripts won't work. I documented them and modified the scripts to be more verbose when unpacking and properly repack the img from the kernel and cpio image.
To note, it seems the kernel parameter for mem=xxx is very important, because the A50 loads firmware (I think for the wifi chip) at boot into the memory space.
To grab and flash boot/recovery images, you need flash_image and dump_image.
After remounting the system partition as rw, both should be placed into the /system/bin folder on the phone and have the following commands run as su:
chmod 0755 /system/bin/dump_image
chmod 0755 /system/bin/flash_image
chown root.root /system/bin/dump_image
chown root.root /system/bin/flash_image
Note that root.root may be 0.0 or root:root or 0:0 -- depending on your busybox version.
The 0 in 0755 designates it as a system app, won't work without it.
To flash a partition, you need to zero it first or the flash won't work. Always test a boot image on the recovery partition first so you don't accidentally brick your phone.
mtd0 is the boot partition
mtd2 is the recovery partition
Take a backup first, by running the following as root:
dump_image recovery /sdcard/recovery.stock.img
dump_image boot /sdcard/boot.stock.img
The dumps will be of the entire partition, so they will be 12MB or so, far bigger than the ones you repack by yourself.
To flash a .img to recovery from the sdcard, run the following as root:
cat /dev/zero > /mnt/mtd/mtd2
A message about reaching the end is normal. Then run:
flash_image recovery /sdcard/recovery.img
You will get a ton of messages flying by regarding skipping blocks. This is normal. It is due to the flash not filling the entire partition.
To flash boot, once you have verified that it works by flashing it to recovery and doing a reboot recovery. If it boots, then flash the original recovery back and verify it works by again doing reboot recovery. This ensures that you will potentially be able to recover from a bad boot flash.
Did I mention that before doing anything you should grab the stock recovery, unpack it, and change it to ro.secure=0 and adb.persist=1 and add in dump_image and flash_image so you will get automatic root when connecting via adb and be able to flash.
May 17, 2011 at 11:08 AM
On another note, I have not been able to get fastboot to be productive, but from looking at the sources, fastboot is provided in the boot or recovery image.
From what I gather, you have to boot into fastboot using the hardware key during boot (opposite of the key that wipes the phone. I forgot if that is left or right... I am writing this all from memory).
In any case, once you get the blue screen, that is a minimal implementation of fastboot that seemingly supports almost nothing. To communicate with it, you have to use the fastboot executable on the PC and specify the device identifier or it will not see the phone.
You then give it the fastboot command to reboot into bootloader, which gives you another blue screen that says "into fastboot". I believe this is built into the kernel because the source describes allowing different features based on different scenarios. Here is how I interpreted the source comments:
-Fastboot is provided by the recovery image via kernel modules, specifically the gadgt and oem ko files in the recovery image.
-Kernel parameters are important. It looks for a boot mode of 1 (I think that is the right mode... whichever is recovery) and a factory_mode of 1 to give full functionality.
-The power level provided to USB is important depending on what you are doing and what it will respond to.
-There are three power modes... low power, normal, and full power.
-To specify the power mode you hold the volume key, I presume during the switch from the hardware fastboot to the gadget-based one. Not holding volume gives you normal power, volume up and down give you low or high (I forgot which is which).
-The power mode using volume keys only works if you have a dev phone or boot using the kernel parameter of factory_mode=1
Asus heavily modified the kernel to deal with different hardware like the carmount power level and detection, so there are two options... either stick with 2.6.29 or locate all of the modifications and integrate them into the current kernel.
Hope this proves useful. Using the instructions you provided for building the kernel, I am going to first try to compile one of the newer 2.6.29 kernels that was released in the A50 source, then move on to Cyanogen.
May 17, 2011 at 4:04 PM
I just realized I had something backward... the ones from Asus are slightly older. The 4.x sources on the Garmin-Asus website have additional tools in the ROM and is laid out differently. Not sure if any of them are useful, but they're in the 4.x sources (which I think is Android 1.6)
May 18, 2011 at 6:37 AM
Get a dropbox account and start putting your stuff on there. You get 2gbs for free, there's no spam or ads.
I've been pretty busy with work, so I haven't had much spare time to post. But I have been trying to get Froyo from CyanogenMod compiled. I get a good way into it to before it fails. The only thing I'm worried about is mount points. When I compile and test out Clockwork Recovery, I always get 'can't find /cache partition'. I did manage to trick it into seeing the /storage as /cache, which worked, and didn't throw any errors. But, we need a real /cache partition to get anything done right, you know? Any suggestions?
(Don't mind me if I seem to not know what I'm talking about, just started learning all this crap... Gotten as far as I have just by Googling the hell out of it, lol.)
May 19, 2011 at 12:18 AM
I feel the same way, except for the kernel compilation side of things... I'm a C#/SQL (read:Windows) developer by trade and haven't done much with Linux in nearly a decade :) I'm good at making educated guesses at reverse engineering and piecing together 10 people's research as well as my own research to hack around inside of firmware. That I've been doing for years. Most of what I've learned has been trial and error, so it's good to see someone actually following some set of coherent directions.
I've looked inside of nearly every script as well as inside of all of the executables for text strings (you'd be amazed at how much of the inner-workings of the phone you can get from opening up binary files in a text editor). That got me a long way :)
As for the cache partition, it's not actually a partition...
Look at /init.rc, it shows exactly how it creates it. It uses the following commands:
mkdir /data/cache 0770 system cache
symlink /data/cache /cache
chown system cache /cache
chmod 0770 /cache
So, the cache partition is actually just a folder inside of mtd3 (userdata). However, that syntax of mkdir is foreign to me and doesn't work with busybox's version of mkdir. It tries to create 4 folders :)
I think changing that line to mkdir /system/cache would suffice, since it applies permissions and ownership in the last two lines.
May 19, 2011 at 12:33 AM
Also, I will be testing out the restore functionality of the system image that gets created by romdump... or not if you can verify something for me...
Does your market show the AppBrain app? Mine can't find about 5 of the key pieces of Software I use, including the T-Mobile MyAccount app... Apparently the most likely culprit is the Device Fingerprint, but that doesn't make sense at all considering other T-Mobile apps are there, and the ONLY ones missing are ones I have previously used. I've gone so far as to restore the boot, recovery, misc, fota, and eng_data images that I made immediately after upgrading to 2.1 initially, including a Master Reset before and after, different versions of the market, clearing the market data, fixing permissions, etc... all with no success.
If I install an APK of it from my SD or Titanium Backup, it will sometimes see updates, but I click on it in the "My Apps" in the market and it fails to find it. But I can long press it and click "Update" and that will work :)
If you could check and see if AppBrain App Market is listed when you search for apps, then I'm going to re-flash the entire carrier and userdata partitions, which I haven't yet done.
And if all else fails, I'm going to take the system.img from the offical 2.1 update, mount it as a loop device directly on the phone, and clear out every partition (after backing up the actual Garmin files in /storage) in recovery mode and attempt to start from scratch.
BTW, It would behoove you to do a dump_image on EVERY mtd partition and tar up the /storage folder to an archive on your SD directly on the device over ADB... there are scripts on the phone that WILL destroy your /storage partition if executed... meant to restore the phone to a clear state. You can make it work again using a couple different garmin updaters that will recreate files, but it's a pain in the ass :)
May 20, 2011 at 7:36 AM
Still trying to compile a working Froyo, compiling keeps failing, making a little progress though, just slowly.
Can you post some information about the different loader addresses and kernel boot parameters, etc? Maybe even those packing/repacking scripts? Trying to get BoardConfig.mk setup properly.
With what you've said so far(which is a lot and awesome!) there's one property in BoardConfig.mk that worries me a little, that's BOARD_KERNEL_BASE := XXX. I'm not entirely sure what that value should be, I'm assuming the default one provided is not the correct one. Any ideas?
May 25, 2011 at 10:20 AM
You'll have two options for kernels... Either try to make Froyo work with the Asus kernel, or do a diff on the Asus kernel vs the stock 2.6.29 kernel.
There are a TON of customizations to the kernel, for various things like the aux port on the side (used for the car mount kit). A lot of their stuff is done with kernel modules, so I don't even know how far you'll get. I wouldn't recommend the second route unless you want a world of frustration... however, I don't know if Froyo can work with the Asus 2.6.29 kernel and what modifications may be necessary.
I'm transferring the files that have that info and will get that info. How should I get the scripts up? One of them is Python, and it doesn't play nicely with bad formatting.
May 25, 2011 at 1:47 PM
Get a dropbox account, zip everything, and upload them to your Public folder, then post the links to those files here. That's the easiest way.
I would like to try and compile an overclock'able Kernel, that would be a great start. Granted I don't know where stuff like that would be stored in the source code(couldn't find anything obvious). Then pack a boot.img with your modified scripts, share to the world of Garminfone users(not a very big one but...).
May 26, 2011 at 4:35 AM
w00t that would be great. sys/devices/system/cpu0?
June 21, 2011 at 2:37 AM
Hi all,
PLEASE PLEASE PLEASE keep up the good work - one day we will break through with this damn ROM.
In the mean time I have a simple (I hope) question. I am trying to change the firmware from one country to another, the reason; I bought the phone in Australia it was network locked the Optus network. Since I have paid the $100.00 network unlocking fee and want to put it on the Australian Telstra 3g network which runs on the 850mhz frequency. I am pretty sure when Optus put out their 2.1 Australian update they locked this frequency down. So I am hoping to change to say the European firmware (2.1) to open up the frequency again. Any help would be so so so much appreciated.
I have the phone rooted and have tried with no success to install reboot on recovery (via adb commands) and have obviuosly simply tried the updates from other countires but these say "invalid system file" Garmin are simply not interested.
Thanks AGAIN.