错误提示如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
[ 86% 1602/1858 13m53s remaining] Target userdata fs image: out/target/product/tangorpro/userdata.img
FAILED: out/target/product/tangorpro/userdata.img
/bin/bash -c "(mkdir -p out/target/product/tangorpro/data ) && (mkdir -p out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates && rm -rf out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"userdata_fs_type=f2fs\"
>> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"userdata_size=11796480000\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"needs_casefold=1\" >> out/targe
t/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"needs_projid=1\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"needs_compress=1\" >> out/target/product/tangorpro/obj/P
ACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"userdata_selinux_fc=out/target/product/tangorpro/obj/ETC/file_contexts.bin_intermediates/file_contexts.bin\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) &
& (echo \"building_userdata_image=true\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"ext_mkuserimg=mkuserimg_mke2fs\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt
) && (echo \"fs_type=ext4\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"extfs_sparse_flag=-s\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"erofs_spar
se_flag=-s\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"squashfs_sparse_flag=-s\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"f2fs_sparse_flag=-S\"
>> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"ext4_share_dup_blocks=true\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"avb_avbtool=avbtool\" >> out/ta
rget/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"root_dir=out/target/product/tangorpro/root\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"use_dynamic_partition_size
=true\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (echo \"skip_fsck=true\" >> out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (sort -o out/target/product/tangorpro/obj/P
ACKAGING/userdata_intermediates/userdata_image_info.txt out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt ) && (PATH=out/host/linux-x86/bin/:system/extras/ext4_utils/:\$PATH out/host/linux-x86/bin/build_image --input-directory-filter-
file out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/file_list.txt out/target/product/tangorpro/data out/target/product/tangorpro/obj/PACKAGING/userdata_intermediates/userdata_image_info.txt out/target/product/tangorpro/userdata.img out/target/product/tango
rpro/system ) && (size=\$(for i in out/target/product/tangorpro/userdata.img; do stat -c \"%s\" \"\$i\" | tr -d '\\n'; echo +; done; echo 0); total=\$(( \$( echo \"\$size\" ) )); printname=\$(echo -n \"out/target/product/tangorpro/userdata.img\" | tr \" \" +); maxsize=\$((11
796480000)); if [ \"\$total\" -gt \"\$maxsize\" ]; then echo \"error: \$printname too large (\$total > \$maxsize)\"; false; elif [ \"\$total\" -gt \$((maxsize - 32768)) ]; then echo \"WARNING: \$printname approaching size limit (\$total now; limit \$maxsize)\"; fi )"
2024-06-25 11:47:15 - build_image.py - ERROR : Failed to build out/target/product/tangorpro/userdata.img from out/target/product/tangorpro/tmpfx91jc63
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/media/tangorpro14/out/host/linux-x86/bin/build_image/__main__.py", line 12, in <module>
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "build_image.py", line 1041, in <module>
File "build_image.py", line 1034, in main
File "build_image.py", line 936, in BuildImageOrVBMeta
File "build_image.py", line 649, in BuildImage
File "build_image.py", line 447, in BuildImageMkfs
File "common.py", line 328, in RunAndCheckOutput
common.ExternalError: Failed to run command '['mkf2fsuserimg', 'out/target/product/tangorpro/userdata.img', '11796480000', '-S', '-f', 'out/target/product/tangorpro/tmpfx91jc63', '-D', 'out/target/product/tangorpro/system', '-s', 'out/target/product/tangorpro/obj/ETC/file_co
ntexts.bin_intermediates/file_contexts.bin', '-t', 'data', '-L', 'data', '--prjquota', '--casefold', '--compression', '-b', '4096']' (exit code 4):
in mkf2fsuserimg.sh PATH=out/host/linux-x86/bin/:system/extras/ext4_utils/:/media/tangorpro14/prebuilts/build-tools/path/linux-x86:/media/tangorpro14/out/.path
make_f2fs -g android -S 11796480000 -l data -O project_quota,extra_attr -O casefold -C utf8 -O compression,extra_attr -b 4096 -w 4096 out/target/product/tangorpro/userdata.img

F2FS-tools: mkfs.f2fs Ver: 1.16.0 (2023-04-11)

Info: Disable heap-based policy
Info: Debug level = 1
Info: Label = data
Info: Trim is disabled
Info: Set conf for android
Info: Enable utf8 with casefolding
Info: Enable Project quota
Info: Enable Compression
Info: not exist /proc/version!
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 23040000 (11250 MB)
Info: zone aligned segment0 blkaddr: 512
Info: add quota type = 0 => 4
Info: add quota type = 1 => 5
Info: add quota type = 2 => 6
Info: format version with
"6.2.0-33-generic"
[f2fs_init_sit_area: 648] Filling sit area at offset 0x00600000
[f2fs_init_nat_area: 682] Filling nat area at offset 0x00a00000
[f2fs_add_default_dentry_root:1265] Writing default dentry root, at offset 0x5a00
[f2fs_write_root_inode:1310] Writing root inode (hot node), offset 0x5400
[f2fs_write_default_quota:1397] Writing quota data, at offset 00005a01 (1/2)
[f2fs_write_default_quota:1397] Writing quota data, at offset 00005a02 (2/2)
[f2fs_write_qf_inode:1448] Writing quota inode (hot node), offset 0x5401
[f2fs_write_default_quota:1397] Writing quota data, at offset 00005a03 (1/2)
[f2fs_write_default_quota:1397] Writing quota data, at offset 00005a04 (2/2)
[f2fs_write_qf_inode:1448] Writing quota inode (hot node), offset 0x5402
[f2fs_write_default_quota:1397] Writing quota data, at offset 00005a05 (1/2)
[f2fs_write_default_quota:1397] Writing quota data, at offset 00005a06 (2/2)
[f2fs_write_qf_inode:1448] Writing quota inode (hot node), offset 0x5403
[f2fs_update_nat_default:1485] Writing nat root, at offset 0x00000a00
Info: Overprovision ratio = 1.410%
Info: Overprovision segments = 79 (GC reserved = 77)
[f2fs_write_check_point_pack: 864] Writing main segments, cp at offset 0x00000200
[f2fs_write_check_point_pack: 952] Writing Segment summary for HOT/WARM/COLD_DATA, at offset 0x00000201
[f2fs_write_check_point_pack: 966] Writing Segment summary for HOT_NODE, at offset 0x00000202
[f2fs_write_check_point_pack: 978] Writing Segment summary for WARM_NODE, at offset 0x00000203
[f2fs_write_check_point_pack: 989] Writing Segment summary for COLD_NODE, at offset 0x00000204
[f2fs_write_check_point_pack: 997] Writing cp page2, at offset 0x00000205
[f2fs_write_check_point_pack:1017] Writing NAT bits pages, at offset 0x000003ff
[f2fs_write_check_point_pack:1038] Writing cp page 1 of checkpoint pack 2, at offset 0x00000400
[f2fs_write_check_point_pack:1057] Writing cp page 2 of checkpoint pack 2, at offset 0x00000405
[f2fs_write_super_block:1090] Writing super block, at offset 0x00000000
Info: format successful
sload_f2fs -S -f out/target/product/tangorpro/tmpfx91jc63 -p out/target/product/tangorpro/system -s out/target/product/tangorpro/obj/ETC/file_contexts.bin_intermediates/file_contexts.bin -t /data out/target/product/tangorpro/userdata.img

Out of space? Out of inodes? The tree size of out/target/product/tangorpro/tmpfx91jc63 is 582656 bytes (0 MB), with reserved space of 0 bytes (0 MB).
The max image size for filesystem files is 11796480000 bytes (11250 MB), out of a total partition size of 11796480000 bytes (11250 MB).
11:47:16 ninja failed with: exit status 1

#### failed to build some targets (09:44 (mm:ss)) ####

从最后的提示分析 ,两个size是一样的,都是11796480000,说不是分配system.img大小的问题,系统自己重算了。Google之后,参考

https://stackoverflow.com/questions/62473888/android-aosp-build-failing-in-build-image-py-for-android-10-0-0-r39

在/device/google/tangorpro/tangorpro/BoardConfig.mk增加

1
BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE := ext4 

重新clean,build之后,错误变成了:

1
2
3
4
mkfs.f2fs 

Info: open /dev/loop0 failed errno:13
Error: Not available on mounted device!

问GPT,需要把当前用户加入disk组:

1
2
$sudo usermod -aG disk <username>

注销后,再编译成功。