Resize system and install GAPPS with android6 image.

Discuss Android on the Wandboard, as well as app development for or on the Wandboard.

Resize system and install GAPPS with android6 image.

Postby freed » Sun Mar 26, 2017 8:52 pm

The flashcard script from the README.pdf does not work for me. Since I could not find a matching sfdisk.

But the easiest way is to "dd" the following image.
Download the image from here:
http://download.wandboard.org/wandboard ... 160428.zip

A) Create bootable sd-card
Dump image to the sd-card.
Take care to select the proper device. In general /dev/sd[a..z] is your sd-card. Here I write "/dev/sdX" rename this to your sd-card device.
Code: Select all
dd if=wandboard-all-android-6.0.1-sdcard-20160428.zip of=/dev/sdX bs=4M

Unfortunately the system partition of the image is too small to install the GAPPS. So this is what I did:

B) Backup
Once the image is on the sd-card, backup all partitions.
Code: Select all
sudo dd if=/dev/sdX1 of=wb6_p1_boot.img bs=4k     # not needed later on, but to be sure
sudo dd if=/dev/sdX2 of=wb6_p2_recover.img bs=4k # not needed later on, but to be sure
sudo dd if=/dev/sdX4 of=wb6_p4_data.img bs=4k
sudo dd if=/dev/sdX5 of=wb6_p5_system.img bs=4k
sudo dd if=/dev/sdX6 of=wb6_p6_cache.img bs=4k
sudo dd if=/dev/sdX7 of=wb6_p7_device.img bs=4k


C) Repartition
For the next step you need to be familiar with a tool like fdisk or (g)parted:
1. Than delete all partitions except of p1(boot), p2(recovery) and the extended.
2. Enlarge the extended partitions to at least 2GB.
3. Create a new ext4 primary partition and label the partition data from the end of the extended partition of the end of your sd-card.
4. Create a new ext4 logical partition and label the partition system. The size should be at least 1GB better 2GB.
5. Create a new ext4 logical partition and label the partition cache. The size should be at least 512MB better 1GB.
6. Create a new ext4 logical partition and label the partition device. The size should be at least 16MB.

D) Write back the backup images:
Code: Select all
sudo dd of=/dev/sdX4 if=wb6_p4_data.img bs=4k
sudo dd of=/dev/sdX5 if=wb6_p5_system.img bs=4k
sudo dd of=/dev/sdX6 if=wb6_p6_cache.img bs=4k
sudo dd of=/dev/sdX7 if=wb6_p7_device.img bs=4k


E) Resize the file system to the maximum of the partition:
Code: Select all
sudo resize2fs -p /dev/sdd4
sudo resize2fs -p /dev/sdd5
sudo resize2fs -p /dev/sdd6
sudo resize2fs -p /dev/sdd7


F) Download the open gapps, from here:
http://opengapps.org
Select arm, android 6, pico

G) Extract the gapps and copy the files into the system partition (p5) of your sd-card.
Change the name of the downloaded gapps tar archive file. Install lzip if not already installed. Call the extract_gapps.sh script.
Copy the extraced files to the sd-card.
Code: Select all
cd gapps/sys
cp -arv * /media/YOURUSER/system

Remove no longer used PacketInstaller
Code: Select all
rm -rf /media/YOURUSER/system/priv-app/PackageInstaller


H) First boot
Insert the sd-card and boot your wandboard.
You will see some failures that the Setup and PlayStore could bot be loaded. Do not care go ahead with the next step to set the permissions.

I) Fix permissions
Since the adb via TCP is not enabled you have to connect to the serial port of your wandboard /dev/ttyXXX, 115400,8,n,1
Code: Select all
pm grant com.google.android.gms android.permission.ACCESS_COARSE_LOCATION
pm grant com.google.android.gms android.permission.ACCESS_FINE_LOCATION
pm grant com.google.android.setupwizard android.permission.READ_PHONE_STATE
pm grant com.google.android.setupwizard android.permission.READ_CONTACTS
Attachments
extract_gapps.sh
(1.28 KiB) Downloaded 37 times
freed
 
Posts: 1
Joined: Sun Mar 26, 2017 6:46 pm

Re: Resize system and install GAPPS with android6 image.

Postby rfindley » Thu Aug 24, 2017 7:18 am

Some notes from my experience building Android 6.0.1:

1. Downloaded the source from http://download.wandboard.org/wandboard ... droid-6.0/

2. There's a PDF file in the source zip with build instructions.

3. This needs openjdk-7 for the build process, which isn't available in the default packages on Ubuntu 16.04, so I used an older Ubuntu 14.04.

4. I had to install a few packages, including openjdk-7-jdk and lzip (maybe one or two others?)

5. I found I needed 4GB of RAM (started with 2GB in my virtual machine)

6. You don't need to resize the partitions manually! :D You can edit <android_source>/device/fsl/common/tools/fsl-sdcard-partition.sh, which contains the settings for partition sizes:
Code: Select all
   SYSTEM_ROM_SIZE=2048    (<-- it was 800)
   CACHE_SIZE=1024    (<-- was 512)


7. When it comes time to write the image to sdcard, the 'flashcard' command had an error, where it couldn't find 'mkimage'. Well, mkimage is in the PATH, but it tries to run it with 'sudo', and the PATH changes when you run sudo. So, I edited <source>/cookers/env.bash.imx6.edm1cf-sd.wandboard.hdmi (or the other env file if you're on RevD1) to copy the PATH through the sudo command. If you search for "ramdisk" in that script, you'll see a line a few lines down which looks like this:
    sudo mkimage -A arm -O linux -T ramdisk...
Add the following:
    sudo env "PATH=$PATH" mkimage -A arm -O linux -T ramdisk...

8. It's important to note that you need to install GApps *before* you boot from the sdcard.
You'll be installing GApps to partition 5 of the sdcard.
In @freed's instructions (above), it took me a while to realize where extract_gapps.sh was supposed to come from. It's attached to his post (duh!). I was looking for it in the gapps zip.
The extract_gapps.sh script needs to be in the same folder as the gapps zip.
You need to edit extract_gapps.sh to make the timestamp and gapps version (pico, nano, etc.) match the version of gapps that you downloaded.
After running extract_gapps.sh, you'll have a new subfolder called 'gapps'. That's when you run @freed's command "cd gapps/sys", and "cp -arv <destination>"
The files (in ./gapps/sys) need to be copied to the root of partition 5. In @freed's instructions, "/media/YOURUSER/system" is where he mounted partition 5. So, for example, if you manually mount partition 5:
Code: Select all
       mkdir partition5
       sudo mount /dev/sdb5 partition5
       cd gapps/sys
       sudo cp -arv * ../../partition5
       sudo umount ../../partition5


9. After booting Android, I ran @freed's commands to fix permissions. This should be obvious, but I confused myself when trying to figure out how to run the commands. I had my serial line connected to the Wandboard's serial port (you need a null-modem serial adapter, by the way), but also had a keyboard hooked up to the USB port. I kept typing on the USB keyboard instead of the PC keyboard, so I was sending keystrokes to the Android GUI instead of to the serial console. (Doh!)
Anyway, you'll have tons of errors and crashing apps until you get the permissions fixed.

Hopefully, this will save someone some time.
Last edited by rfindley on Tue Aug 29, 2017 9:19 am, edited 1 time in total.
rfindley
 
Posts: 22
Joined: Fri Nov 22, 2013 7:44 pm

Re: Resize system and install GAPPS with android6 image.

Postby Booleano » Mon Aug 28, 2017 1:29 pm

Hi,

is it possible to run a script from at boot time from the sdcard to run the pm grant commands,

to avoid using a serial cable?


thanks and regards
Booleano
 
Posts: 7
Joined: Tue Mar 22, 2016 7:29 pm

Re: Resize system and install GAPPS with android6 image.

Postby rfindley » Tue Aug 29, 2017 9:19 am

@Booleano

Here's a way you can automate the fixing of the permissions. We'll add a service (in this case, a script file) that will run at startup, sleep for 5 minutes (300 seconds), then run the permissions commands.

If you haven't already, run 'make' to build everything, according to the normal build instructions.

Some setup:
Code: Select all
cd <android_source>
source cookers/env.bash.imx6.edm1cf-sd.wandboard.hdmi
export PATH=$PATH:${TOP}/out/host/linux-x86/bin
cd out/target/product/wandboard/


We need to mount the system_raw.img, which will later get copied to partition 5 of the sdcard:
Code: Select all
mkdir mnt
sudo mount system_raw.img mnt


Now we''ll add our script file to the /system/bin folder:

Code: Select all
sudo nano mnt/bin/fix_perms.sh


Insert this code into the editor:
Code: Select all
#!/system/bin/sh

while true;
do
  sleep 300
  /system/bin/pm grant com.google.android.gms android.permission.ACCESS_COARSE_LOCATION
  /system/bin/pm grant com.google.android.gms android.permission.ACCESS_FINE_LOCATION
  /system/bin/pm grant com.google.android.setupwizard android.permission.READ_PHONE_STATE
  /system/bin/pm grant com.google.android.setupwizard android.permission.READ_CONTACTS
done &

(I'm assuming you're familiar with nano... ctrl-x to save and exit)

Give the script the correct ownership and permissions:
Code: Select all
sudo chown root:2000 mnt/bin/fix_perms.sh
sudo chmod 755 mnt/bin/fix_perms.sh


If you want to merge GApps directly into the system_raw.img (while we still have it mounted), rather than onto the sdcard later, you can do so now:
Code: Select all
cd path/to/gapps/sys
sudo cp -arv * ${TOP}/out/target/product/wandboard/mnt/
cd ${TOP}/out/target/product/wandboard
sudo rm -rf mnt/priv-app/PackageInstaller


We can unmount the system_raw.img now:
Code: Select all
sudo umount mnt
rmdir mnt


We need to tell Android to call our script. This is done in init.freescale.rc:
Code: Select all
nano root/init.freescale.rc


Near the end of the file (a dozen or so lines from the bottom), find the following lines:
Code: Select all
service eth_updown /system/bin/eth_updown start
    class late_start
    oneshot


Immediately after that, add a new service:
Code: Select all
service fix_perms /system/bin/fix_perms.sh start
    class late_start
    oneshot

(save and exit)

Now we need to repackage init.freescale.rc into ramdisk.img:
Code: Select all
mkbootfs -d system root | minigzip >ramdisk.img


And finally, we're ready to write everything to the sdcard:

Code: Select all
cd $TOP
flashcard /dev/sdX

(replace sdX with whatever the device name of your sdcard is)

(If you didn't add GApps to the system_raw.img, you'll want to add it directly to the sdcard now using the method in earlier posts).

When you boot, you'll need to wait at least 6 minutes: 30 seconds before it runs our script, and the script sleeps for 5 minutes. Assuming your sdcard isn't too slow, this should give GApps plenty of time to install before our permissions are set.
Just leave it alone during that time, even if the screen goes blank.

After 6 minutes, you're ready to go!

One problem I've found with this ROM so far is that the HDMI doesn't carry audio. The audio stays on the audio jack of the wandboard. But I was able to use SoundAbout app to force the audio to HDMI. I don't know enough about Android internals yet to change it in the configuration.
rfindley
 
Posts: 22
Joined: Fri Nov 22, 2013 7:44 pm

Re: Resize system and install GAPPS with android6 image.

Postby Booleano » Sat Sep 02, 2017 7:04 am

Hi,
thanks a lot of this , so this require a rebuild of the image.
Is there the possibiltiy to do the same on the original images posted?

Also, I tried the existing images with kodi but the performance of the video are very poor compared to linux distro like geexbox, or arch.
Did you try kodi on the build you did?

thanks
Booleano
 
Posts: 7
Joined: Tue Mar 22, 2016 7:29 pm

Re: Resize system and install GAPPS with android6 image.

Postby rfindley » Sat Sep 02, 2017 7:35 pm

@Booleano,

I don't know whether the original images need those permissions commands or not.
To use the method I described above without a rebuild, you would need to unpack the ramdisk.img on partition 1, modify init.freescale.rc, and repack the ramdisk.img. I don't enough about the ramdisk.img to know how to unpack it.
If you could figure out the ramdisk part, adding the fix_perms.sh script is easy. Just mount partition 5, and add the fix_perms.sh to /bin/
rfindley
 
Posts: 22
Joined: Fri Nov 22, 2013 7:44 pm

Re: Resize system and install GAPPS with android6 image.

Postby Gonly1998 » Thu Oct 26, 2017 5:26 pm

it doesnt work for me either. help!!!
Gonly1998
 
Posts: 10
Joined: Thu Oct 26, 2017 5:15 pm


Return to Software - Android

Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests