I'm able to build an modified AOSP Emualtor for x86. This one builds and starts properly.
Now, I want to build same for arm64 (Apple Silicon M1)
I fetched the android aosp mainline tree (next fetch --target my_car_emu-mainline)
Then I created a new device based on device/my/my_car_emu
that mean I added a new folder by copying the my_car_emu one there for example my_car_emu_arm64
add this new folder to AndroidProducts.mk
change your Boardconfig.mk and my_car_emu_arm64.mk to set up for arm64 architecture instead of x86_64
next shell --target my_car_emu-mainline then lunch … select
it In same shell, I was to build (make -jX)
During start I see ...
The root cause
VERBOSE | Could not find SDK version in build.prop, default is: 10000
VERBOSE | autoconfig: -skin HVGA
VERBOSE | autoconfig: -skindir (null)
ERROR | bad workspace: cannot find prebuilt ranchu kernel in: /Users/hannes/Library/Android/sdk/prebuilts/qemu-kernel/arm/ranchu/kernel-qemu
ERROR | This AVD's configuration is missing a kernel file! Please ensure the file "kernel-ranchu" is in the same location as your system image.
ERROR | ANDROID_SDK_ROOT is defined (/Users/hannes/Library/Android/sdk) but cannot find kernel file in /Users/hannes/Library/Android/sdk/system-images/ sub directories
My current unsuccessful solution for root cause
cp ~/Library/Android/sdk/system-images/android-30/google_apis/arm64-v8a/kernel-ranchu ~/MY/my_car_emu_arm64
Now I see
[ 0.184786] uart-pl011 9000000.pl011: no DMA platform data
[ 0.185313] Freeing unused kernel memory: 1216K
[ 0.207918] cryptomgr_probe (109): highest shadow stack usage: 168 bytes
[ 0.215882] Run /init as init process
[ 0.216987] init: init first stage started!
[ 0.217330] init: Unable to open /lib/modules, skipping module loading.
[ 0.217984] init: Using Android DT directory /proc/device-tree/firmware/android/
[ 0.218675] init: [libfs_mgr]ReadDefaultFstab(): failed to find device default fstab
[ 0.222438] init: bool android::init::BlockDevInitializer::InitDevices(std::set<std::string>): partition(s) not found in /sys, waiting for their uevent(s): system, vendor
[ 10.236993] init: Wait for partitions returned after 10013ms
[ 10.239044] init: bool android::init::BlockDevInitializer::InitDevices(std::set<std::string>): partition(s) not found after polling timeout: system, vendor
[ 10.242109] init: Failed to mount required partitions early ...
[ 10.243405] init: InitFatalReboot: signal 6
[ 10.253935] init: #00 pc 0000000000302920 /init (UnwindStackCurrent::UnwindFromContext(unsigned long, void*)+96)
[ 10.255564] init: #01 pc 0000000000274e88 /init (android::init::InitFatalReboot(int)+208)
[ 10.256827] init: #02 pc 0000000000275268 /init (android::init::InstallRebootSignalHandlers()::$_22::__invoke(int)+32)
[ 10.258463] init: #03 pc 00000000000005c0 [vdso:0000007f811f1000] (__kernel_rt_sigreturn)
[ 10.259719] init: #04 pc 0000000000376884 /init (abort+160)
[ 10.260565] init: #05 pc 0000000000277b74 /init (android::init::InitAborter(char const*)+44)
[ 10.261705] init: #06 pc 00000000002c4f28 /init (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+76)
[ 10.263498] init: #07 pc 00000000002c4748 /init (android::base::LogMessage::~LogMessage()+320)
[ 10.264660] init: #08 pc 000000000026ca38 /init (android::init::FirstStageMain(int, char**)+5796)
[ 10.265849] init: #09 pc 000000000037571c /init (__real_libc_init(void*, void (*)(), int (*)(int, char**, char**), structors_array_t const*, bionic_tcb*)+576)
[ 10.267716] init: Reboot ending, jumping to kernel
[ 10.268635] cfg80211: failed to load regulatory.db
[ 10.269356] reboot: Restarting system with command 'bootloader'
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x00000000]
[ 0.000000] Linux version 5.4.86-android11-2-00040-g29b2beadc627-ab7157994 (build-user#build-host) (Android (6443078 based on r383902) clang version 11.0.1 (https://android.googlesource.com/toolchain/llvm-project b397f81060ce6d701042b782172ed13bee898b79), LLD 11.0.1 (/buildbot/tmp/tmp6_m7QH b397f81060ce6d701042b782172ed13bee898b79)) #1 SMP PREEMPT Fri Feb 19 11:59:46 UTC 2021
[ 0.000000] Machine model: linux,ranchu
New root cause
partition(s) not found in /sys, waiting for their uevent(s): system, vendor
I want to run custom kernel ( goldfish ) on android-9 (API 28) avd.
So I just downloaded goldfish kernel:
git clone https://android.googlesource.com/kernel/goldfish/ -b android-4.4
make x86_64_ranchu_defconfig
make -j4
then I run emulator :
emulator -avd test -kernel goldfish/arch/x86/boot/bzImage -show-kernel
But there is some error between my kernel and SELinux policy of vendor.
Here the logs:
[ 1.170669] init: init first stage started!
[ 1.172289] init: Using Android DT directory /sys/bus/platform/devices/ANDR0001:00/properties/android/
[ 1.174652] init: First stage mount skipped (missing/incompatible fstab in device tree)
[ 1.176724] init: Skipped setting INIT_AVB_VERSION (not in recovery mode)
[ 1.178464] init: Loading SELinux policy
[ 1.182955] init: No precompiled sepolicy: No such file or directory
[ 1.184557] init: Compiling SELinux policy
[ 1.185672] init: Failed to read /vendor/etc/selinux/plat_sepolicy_vers.txt: No such file or directory
[ 1.188030] init: Unable to load SELinux policy
[ 1.189192] init: Reboot start, reason: reboot, rebootTarget: bootloader
Obviously the system go in boot loop.
How can I fix this?
I am using since Android 4.4 the tool make_ext4fs to repack Samsung system images.
make_ext4fs -s -l [size] -a [mount-point] -S [file_contexts] [out_file] [src_folder]
This works fine for sparsed file systems up to Android 5.1.1. I need to repack an Android 6.0.1 system.img of a Samsung device. There aren't any errors, flashing works too but the Wifi device is broken.
This is the logcat output
...
08-30 13:38:35.489 I/WifiHW ( 2149): wifi_change_fw_path(): fwpath = /system/etc/wifi/bcmdhd_sta.bin
08-30 13:38:35.489 E/WifiHW ( 2149): Cannot open "/data/.cid.info": No such file or directory
...
08-30 13:38:35.809 I/wpa_supplicant( 3181): nl80211: deinit ifname=wlan0 disabled_11b_rates=0
08-30 13:38:35.809 E/wpa_supplicant( 3181): Could not read interface wlan0 flags: No such device
08-30 13:38:35.809 E/wpa_supplicant( 3181): wlan0: Failed to initialize driver interface
...
This the kmsg output
[5.560176] [2: sh: 2269] macloader: Not yet wlan interface loaded
I tried to compare the stock and the repacked images, but they are compressed and not comparable.
Has anything changed with the img format from Android 5.1.1 to Android 6.0.1 or is this a Samsung specific problem? The file_contexts is exracted from the stock boot.img. I think the selinux permissions are fine but I am not sure if the regular permissions are set correrctly. Is there a way to get sure the mac permissions will be preserved?
Update
I've rebuilt make_ext4fs with branch android-6.0.1 according to this link (https://gist.github.com/monyxie/3128671a1f9508b7b9cdcf803e55af1e) which has new options added.
[ -l <len> ] [ -j <journal size> ] [ -b <block_size> ]
[ -g <blocks per group> ] [ -i <inodes> ] [ -I <inode size> ]
[ -L <label> ] [ -f ] [ -a <android mountpoint> ] [ -u ]
[ -S file_contexts ] [ -C fs_config ] [ -T timestamp ]
[ -z | -s ] [ -w ] [ -c ] [ -J ] [ -v ] [ -B <block_list_file> ]
<filename> [[<directory>] <target_out_directory>]
The added option [-C fs_config] let you set the permission of every single file and expects a list of files with its uid / gid / mac-permissions / (optional SELinux context). make_ext4fs throws an error if theres is any file without a config defined.
...
system/bin 0 0 755 u:object_r:system_file:s0
system/bin/iptables 0 0 750 u:object_r:system_file:s0
system/bin/ip6tables 0 0 750 u:object_r:system_file:s0
...
I have been successfully build the android image for the hummingbird and using peonixsuit uploaded the image on board, but not successful in brining the board up following is the log which i am getting in UART0 while booting the board.
Hit any key to stop autoboot: 0
Starting kernel ...
[ 3.294581] init: width = 1024
[ 3.298059] init: height = 600
[ 3.301490] init: s.st_size = 2457600
[ 4.112131] init: do_umount: /data
[ 4.403401] init: do_umount: /cache
[ 4.726198] init: dont need format /dev/block/UDISK
[ 4.944192] init: do_umount: /databk
[ 5.624185] init: cannot find '/system/etc/install-recovery.sh', disabling 'flash_recovery'
[ 6.302551] i2c i2c-1: Invalid 7-bit I2C address 0x00
[ 6.596336] android_usb: already disabled
[ 6.601920] init: using deprecated syntax for specifying property 'sys.usb.config', use ${name} instead
[ 6.649823] init: using deprecated syntax for specifying property 'sys.usb.config', use ${name} instead
[ 31.820483] start_powernow uncare mode:859320624!
[ 32.517665] init: sys_prop: permission denied uid:1003 name:service.bootanim.exit
please help me to solve this issue.
I want to build and run CyanongenMod 10.2 on simulator. First of all, my developer machine is ok (it builds CM 10.2 for crespo, a CM fork for Motorola Defy...CM 10.1 for samsung p4 tablet).
In order to build CM 10.2 for simulator I do the following steps:
breakfast goldfish: download kernel and goldfish releated stuff
mka: do a full build
The build is done: all the .img file are in the $OUT folder. Seems all ok...but if I run "emulator -show-kernel" it blocks with a lot of error :
init: could not import file '/init.carrier.rc' from '/init.rc'
init: do_chown: Could not access /selinux/booleans
init: do_chown: Could not access /sys/fs/selinux/booleans
init: cannot open '/initlogo.rle'
yaffs: dev is 32505856 name is "mtdblock0"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.0, "mtdblock0"
block 1177 is bad
block 1182 is bad
yaffs: dev is 32505857 name is "mtdblock1"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.1, "mtdblock1"
yaffs_read_super: isCheckpointed 0
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
yaffs_read_super: isCheckpointed 0
fs_mgr: Cannot mount filesystem on /dev/block/mtdblock0 at /system
init: fs_mgr_mount_all returned an error
yaffs tragedy: no more erased blocks
[....]
yaffs tragedy: no more erased blocks
init: cannot find '/system/bin/sysinit', disabling 'sysinit'
init: Unable to open persistent property directory /data/property errno: 2
init: cannot find '/system/bin/servicemanager', disabling 'servicemanager'
init: cannot find '/system/bin/vold', disabling 'vold'
init: cannot find '/system/bin/qemu-props', disabling 'qemu-props'
init: cannot find '/system/bin/auditd', disabling 'auditd'
init: cannot find '/system/bin/netd', disabling 'netd'
init: cannot find '/system/bin/debuggerd', disabling 'debuggerd'
init: cannot find '/system/bin/rild', disabling 'ril-daemon'
init: cannot find '/system/bin/surfaceflinger', disabling 'surfaceflinger'
init: cannot find '/system/bin/app_process', disabling 'zygote'
init: cannot find '/system/bin/drmserver', disabling 'drm'
init: cannot find '/system/bin/mediaserver', disabling 'media'
init: cannot find '/system/bin/installd', disabling 'installd'
init: cannot find '/system/bin/keystore', disabling 'keystore'
init: cannot find '/system/bin/handle_compcache', disabling 'compcache'
init: cannot find '/system/bin/qemud', disabling 'qemud'
init: cannot find '/system/bin/logcat', disabling 'goldfish-logcat'
init: cannot find '/system/etc/init.goldfish.sh', disabling 'goldfish-setup'
init: cannot find '/system/bin/sh', disabling 'console'
It seems to be an error with EXT4 image file: emulator does not accept EXT4 filesystem but only yaffs?
The question is simple: is it possible to run a CM build on simulator?
Yeah, I have same issue with you, then I run command:
mkyaffs2image -f out/target/product/generic/system out/target/product/generic/system_yaffs2.img
emulator -kernel out/target/product/generic/zImage -system out/target/product/generic/system_yaffs2.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/data_yaffs2.img -partition-size 1024 -show-kernel -verbose
wait several minutes, the emulator can be launched.
But the ril service seems coredump, so 3G network won't work. I am looking for how to fix this.
I try with another way:
*) edit the system/core/rootdir/init.rc file and change the mount command:
on fs
# mount mtd partitions
# Mount /system rw first to give the filesystem a chance to save a checkpoint
mount ext4 mtd#system /system
mount ext4 mtd#system /system ro remount
mount ext4 mtd#userdata /data nosuid nodev
mount ext4 mtd#cache /cache nosuid nodev
The output is :
fs_mgr: Cannot mount filesystem on /dev/block/mtdblock0 at /system
init: fs_mgr_mount_all returned an error
init: cannot find '/system/bin/sysinit', disabling 'sysinit'
init: Unable to open persistent property directory /data/property errno: 2
init: cannot find '/system/bin/servicemanager', disabling 'servicemanager'
*) using the previous init.rc file, compile a new goldfish kernel from GIT sources and edit the .config file
CONFIG_EXT4_FS=y
CONFIG_EXT4_USE_FOR_EXT23=y
CONFIG_EXT4_FS_XATTR=y
CONFIG_EXT4_FS_POSIX_ACL=y
CONFIG_EXT4_FS_SECURITY=y
Then run the emulator with "emulator -show-kernel -kernel ~/goldfish/arch/arm/boot/zImage"
The output is:
init: could not import file '/init.carrier.rc' from '/init.rc'
init (1): /proc/1/oom_adj is deprecated, please use /proc/1/oom_score_adj instead.
init: do_chown: Could not access /selinux/booleans
init: cannot open '/initlogo.rle'
goldfish_nand_read: invalid read, start 0, len 200, dev_size 21560000, write_size 800
end_request: I/O error, dev mtdblock0, sector 2
EXT4-fs (mtdblock0): unable to read superblock
goldfish_nand_read: invalid read, start 0, len 200, dev_size c200000, write_size 800
end_request: I/O error, dev mtdblock1, sector 2
EXT4-fs (mtdblock1): unable to read superblock
goldfish_nand_read: invalid read, start 0, len 200, dev_size 4000000, write_size 800
end_request: I/O error, dev mtdblock2, sector 2
EXT4-fs (mtdblock2): unable to read superblock
goldfish_nand_read: invalid read, start 0, len 200, dev_size 21560000, write_size 800
end_request: I/O error, dev mtdblock0, sector 2
EXT4-fs (mtdblock0): unable to read superblock
fs_mgr: Cannot mount filesystem on /dev/block/mtdblock0 at /system
init: fs_mgr_mount_all returned an error
init: cannot find '/system/bin/sysinit', disabling 'sysinit'