2019/11/20

build android P for rpi3

依照這個 來做,試試 rpi 3 上 android P

android sources from google.(https://android.googlesource.com/platform/manifest)
依照著clone device/brobwind/rpi3,增加local_manifest, repo sync..
repo init -u https://android.googlesource.com/platform/manifest -b android-9.0.0_r50
repo sync

出現 mkfs.fat Error , 據說是 4.1 版的問題,所以..
build/make$ git diff
diff --git a/tools/fat16copy.py b/tools/fat16copy.py
index c20930a47..18541e88a 100755
--- a/tools/fat16copy.py
+++ b/tools/fat16copy.py
@@ -465,8 +465,8 @@ class fat(object):
     self.bytes_per_cluster = bytes_per_sector * sectors_per_cluster
 
     reserved_sectors = read_le_short(f)
-    assert reserved_sectors == 1, \
-        "Can only handle FAT with 1 reserved sector"
+#    assert reserved_sectors == 1, \
+#        "Can only handle FAT with 1 reserved sector"
 
     fat_count = read_byte(f)
     assert fat_count == 2, "Can only handle FAT with 2 tables"
==> 這樣是沒效的,詳細要參考這邊

然後還有... No module named mako.template
就 apt-get install python-mako

out 目錄用 network , loopback device. clean build 時間:
#### build completed successfully (02:48:25 (hh:mm:ss)) ####
out 目錄總共用掉 54G

因為 out 目錄是 loopback device (disk),所以在 nfs export 時,要加上nohide,crossmnt

燒錄 (SD Card)

到 out/target/product/rpi3 下...
out/target/product/rpi3$ sudo OUT=. ~/zoeymkiihome/pi3p/device/brobwind/rpi3/boot/create_partition_table.sh /dev/sdb
 => Destroy partition table ...

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. 
***************************************************************

GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
 => Install GPT partition table ...
 => Install hybrid MBR partition table ...
 => Install images ....
     => Install: rpiboot(./rpiboot.img) image ...
131072+0 records in
131072+0 records out
67108864 bytes (67 MB, 64 MiB) copied, 17.1989 s, 3.9 MB/s
     => Install: boot_a(./boot.img) image ...
39008+0 records in
39008+0 records out
19972096 bytes (20 MB, 19 MiB) copied, 5.31937 s, 3.8 MB/s
     => Install: system_a(./system.img) image ...
1331200+0 records in
1331200+0 records out
681574400 bytes (682 MB, 650 MiB) copied, 152.134 s, 4.5 MB/s
     => Install: misc(/home/charles-chang/zoeymkiihome/pi3p/device/brobwind/rpi3/boot/images/misc.img) image ...
2048+0 records in
2048+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.336952 s, 3.1 MB/s
     => Install: vendor_a(./vendor.img) image ...
524288+0 records in
524288+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 69.0102 s, 3.9 MB/s
     => Install: oem_bootloader_a(/home/charles-chang/zoeymkiihome/pi3p/device/brobwind/rpi3/boot/images/oem_bootloader_a.img) image ...
8192+0 records in
8192+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 1.17575 s, 3.6 MB/s
     => Install: userdata(/home/charles-chang/zoeymkiihome/pi3p/device/brobwind/rpi3/boot/images/zero_4k.bin) image ...
8+0 records in
8+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 0.0298523 s, 137 kB/s
 => Dump partition table ....
Disk /dev/sdb: 15564800 sectors, 7.4 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): A395EE6C-31A1-4A03-BE8E-6A65F0700662
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 15564766
Partitions will be aligned on 8-sector boundaries
Total free space is 6 sectors (3.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          131111   64.0 MiB    FFFF  rpiboot
   2          131112          133159   1024.0 KiB  FFFF  uboot_a
   3          133160          135207   1024.0 KiB  FFFF  uboot_b
   4          135208          200743   32.0 MiB    FFFF  boot_a
   5          200744          266279   32.0 MiB    FFFF  boot_b
   6          266280         1597479   650.0 MiB   FFFF  system_a
   7         1597480         2928679   650.0 MiB   FFFF  system_b
   8         2928680         2928807   64.0 KiB    FFFF  vbmeta_a
   9         2928808         2928935   64.0 KiB    FFFF  vbmeta_b
  10         2928936         2930983   1024.0 KiB  FFFF  misc
  11         2930984         3455271   256.0 MiB   FFFF  vendor_a
  12         3455272         3979559   256.0 MiB   FFFF  vendor_b
  13         3979560         3987751   4.0 MiB     FFFF  oem_bootloader_a
  14         3987752         3995943   4.0 MiB     FFFF  oem_bootloader_b
  15         3995944         4000039   2.0 MiB     FFFF  frp
  16         4000040         4786471   384.0 MiB   FFFF  swap
  17         4786472        15564766   5.1 GiB     FFFF  userdata
PART: 314F99D5-B2BF-4883-8D03-E2F2CE507D6A B4DDDDC3-FF83-4D95-91DC-4999ADB836DF rpiboot
PART: 314F99D5-B2BF-4883-8D03-E2F2CE507D6A E88B3641-48BB-4D5F-892B-A08B075E6E9F uboot_a
PART: 314F99D5-B2BF-4883-8D03-E2F2CE507D6A 8452CDDF-4B7C-42FA-ACB9-1B279553D720 uboot_b
PART: BB499290-B57E-49F6-BF41-190386693794 4ECCB503-5551-490F-B5D5-9D0BDCAC95D7 boot_a
PART: BB499290-B57E-49F6-BF41-190386693794 E579E168-002E-453B-8161-BE9FE76B1390 boot_b
PART: 0F2778C4-5CC1-4300-8670-6C88B7E57ED6 89313297-5363-4E37-B15E-AC87A1F19379 system_a
PART: 0F2778C4-5CC1-4300-8670-6C88B7E57ED6 28A6E00E-C1C1-481A-A087-142A8933B7C8 system_b
PART: B598858A-5FE3-418E-B8C4-824B41F4ADFC 4A773582-3F2D-4ADD-9AF1-4FAD6D78BB7A vbmeta_a
PART: B598858A-5FE3-418E-B8C4-824B41F4ADFC F60C759C-D9EC-4A65-8A24-3DEB5C214204 vbmeta_b
PART: 6B2378B0-0FBC-4AA9-A4F6-4D6E17281C47 BEB9C837-9DF1-4190-BED5-5F9DAD2AF268 misc
PART: 314F99D5-B2BF-4883-8D03-E2F2CE507D6A 1EBD7A2C-2D8C-4CF2-BDED-535219A036AB vendor_a
PART: 314F99D5-B2BF-4883-8D03-E2F2CE507D6A 2039ACAF-EE39-45E2-A02A-5C5927C5AC43 vendor_b
PART: AA3434B2-DDC3-4065-8B1A-18E99EA15CB7 39E6FD6B-58EB-4FB1-BDC5-378B8D888A5E oem_bootloader_a
PART: AA3434B2-DDC3-4065-8B1A-18E99EA15CB7 BB63D919-A323-477E-B4ED-DB62C707C6C0 oem_bootloader_b
PART: AA3434B2-DDC3-4065-8B1A-18E99EA15CB7 AD200506-D3FC-4CB2-AADD-0E1BDABEFB1C frp
PART: AA3434B2-DDC3-4065-8B1A-18E99EA15CB7 59501E98-7479-4BBF-82B6-0585BBFE83EB swap
PART: 0BB7E6ED-4424-49C0-9372-7FBAB465AB4C 9037D9DF-4E2A-4E1F-8C4E-ADBDDBBF2F71 userdata
開機失敗,發現第一個 partition 沒有東西,把 out/.../rpiboot.img mount 起來看,也沒有東西..

18:04:05 prebuilts/build-tools/linux-x86/bin/ninja 
[prebuilts/build-tools/linux-x86/bin/ninja -d keepdepfile rpibootimage -j 10 -f out/combined-rpi3.ninja -v -w dupbuild=err]
[100% 1/1] 
/bin/bash -c "(echo \"Target rpiboot fs image: out/target/product/rpi3/obj/PACKAGING/rpibootimage_intermediates/rpiboot.img\" ) 
&& (mkdir -p out/target/product/rpi3/obj/PACKAGING/rpibootimage_intermediates/ ) 
&& (dd if=/dev/zero of=out/target/product/rpi3/obj/PACKAGING/rpibootimage_intermediates/rpiboot.img bs=\$((1024*1024)) count=64 ) 
&& (mkfs.fat -n \"rpiboot\" out/target/product/rpi3/obj/PACKAGING/rpibootimage_intermediates/rpiboot.img ) 
&& (for item in  out/target/product/rpi3/rpiboot/bootcode.bin out/target/product/rpi3/rpiboot/fixup_cd.dat 
out/target/product/rpi3/rpiboot/fixup.dat 
out/target/product/rpi3/rpiboot/fixup_db.dat 
out/target/product/rpi3/rpiboot/fixup_x.dat 
out/target/product/rpi3/rpiboot/start_cd.elf 
out/target/product/rpi3/rpiboot/start_db.elf 
out/target/product/rpi3/rpiboot/start.elf 
out/target/product/rpi3/rpiboot/start_x.elf 
out/target/product/rpi3/rpiboot/issue.txt 
out/target/product/rpi3/rpiboot/LICENCE.broadcom 
out/target/product/rpi3/rpiboot/LICENSE.oracle 
out/target/product/rpi3/rpiboot/SHA1SUM 
out/target/product/rpi3/rpiboot/cmdline.txt 
out/target/product/rpi3/rpiboot/config.txt 
out/target/product/rpi3/rpiboot/u-boot-dtok.bin 
out/target/product/rpi3/rpiboot/uboot.env 
out/target/product/rpi3/rpiboot/overlays/chosen-serial0.dtbo 
out/target/product/rpi3/rpiboot/overlays/rpi-uart-skip-init.dtbo 
out/target/product/rpi3/rpiboot/bcm2710-rpi-3-b.dtb 
out/target/product/rpi3/rpiboot/bcm2710-rpi-3-b-plus.dtb 
out/target/product/rpi3/rpiboot/overlays/bcm2710-rpi-3-b-android-fstab.dtbo 
out/target/product/rpi3/rpiboot/overlays/bcm2710-rpi-3-b-cpufreq.dtbo 
out/target/product/rpi3/rpiboot/overlays/pwm-2chan.dtbo 
out/target/product/rpi3/rpiboot/overlays/sdtweak.dtbo 
out/target/product/rpi3/rpiboot/overlays/vc4-kms-v3d.dtbo; 
do if [ \"\`dirname \${item}\`\" = \"out/target/product/rpi3/rpiboot\" ] ;
 then build/make/tools/fat16copy.py out/target/product/rpi3/obj/PACKAGING/rpibootimage_intermediates/rpiboot.img \${item} ; 
fi ; done ) 
&& (for item in overlays; do build/make/tools/fat16copy.py 
out/target/product/rpi3/obj/PACKAGING/rpibootimage_intermediates/rpiboot.img 
out/target/product/rpi3/rpiboot/\${item} ; done ) 
&& (echo \"Install rpiboot fs image: out/target/product/rpi3/rpiboot.img\" ) 
&& (prebuilts/build-tools/linux-x86/bin/acp out/target/product/rpi3/obj/PACKAGING/rpibootimage_intermediates/rpiboot.img out/target/product/rpi3/rpiboot.img )"
Target rpiboot fs image: out/target/product/rpi3/obj/PACKAGING/rpibootimage_intermediates/rpiboot.img
手動把 sd card partition1 mount 起來,把 out/.../rpiboot/ 下的檔案都 copy 過去,就可以開機了。
所以猜是 fat16copy.py 的修改失敗了。

看看mkfs.fat 的 option 有沒有有關 reserved_sector ...
mkfs.fat 4.1 (2017-01-24)
No device specified.
Usage: mkfs.fat [-a][-A][-c][-C][-v][-I][-l bad-block-file][-b backup-boot-sector]
       [-m boot-msg-file][-n volume-name][-i volume-id]
       [-s sectors-per-cluster][-S logical-sector-size][-f number-of-FATs]
       [-h hidden-sectors][-F fat-size][-r root-dir-entries][-R reserved-sectors]
       [-M FAT-media-byte][-D drive_number]
       [--invariant]
       [--help]
       /dev/name [blocks]
也順便看一下 build/make/tools/fat16copy.py,其中 main:
    print("Usage: fat16copy.py   [ ...]")
    print("Files are copied into the root of the image.")
    print("Directories are copied recursively")
看來就是一個很方便直接 copy file 到image file 的 tool,不用 loop mount ..

======== 參考reserved sector = 1
所以就是..
device/brobwind/rpi3$ git diff
diff --git a/build/tasks/rpiboot.mk b/build/tasks/rpiboot.mk
index 10d3d74..871633f 100644
--- a/build/tasks/rpiboot.mk
+++ b/build/tasks/rpiboot.mk
@@ -73,7 +73,7 @@ unique_rpiboot_copy_files_destinations_dirs := $(filter-out .,$(patsubst %/,%,$(
 define build-rpibootimage-target
        mkdir -p $(dir $(1))
        dd if=/dev/zero of=$(1) bs=$$((1024*1024)) count=$(2)
-       mkfs.fat -n "rpiboot" $(1)
+       mkfs.fat -a -R1 -n "rpiboot" $(1)
        for item in $(ALL_INSTALLED_RPIBOOT_FILES); do \
                if [ "`dirname $${item}`" = "$(RPIBOOT_OUT_ROOT)" ] ; then \
                        $(FAT16COPY) $(1) $${item} ; \

沒有留言:

張貼留言