Customize /system mountpoint on Android - android

I'm trying to change a Nexus 5 to use dm-verity module. For that I need to:
invoke an utility called veritysetup during boot before /system is mounted;
(this utility will will create a new device called /dev/mapper/devname);
let /system be mounted on /dev/mapper/devname, not the actual partition.
It looks like the mountpoint is configured on fstab.hammerhead (device/lge/hammerhead). In fact I have another mod working by changing this file. So this seams like the easy part.
I know some filesystems are mounted by init.c (system/core/init), like /dev and /proc, and some are mounted on init.hammerhead (system/core/rootdir), like /acct. But I can find where the request to mount /system is.
Any ideas?

That's not the correct way to do it. To use dm-verity we need to:
build android using "user" build type (default is "eng");
change fstab to include "verify" keyword on fs_mgr_flags.
So, when Android the vold module will find the verity flag and will create the mapper device.
If the system image has a signed hash table and precomputed hash and the root image has the public key everything should just work. We should find that the system partition was mounted on /dev/block/dm-0 instead of /dev/block/platform/msm_sdcc.1/by-name/system and is being verified while being read.

I am having a similar inquiry and the posted answer here is closest related post I have found, certaintly my inquiry is relavant...
Does anyone know where the code that generates or places the fstab files into the stage1 and stage2 boots is, I think there is a bug or missing file somewhere. I can easily change and update things. What file in AOSP actually needs to be edited before building in order to modify or make changes in the fstab file before it is packed into he ramfs stage 1 or stage 2. Also where do I place kernel debug parameters like "pci=nocrs" ?
*Note: The answer accepted here is the correct answer per the aosp source documentation, but it leaves out the same valuable information the source documentation does. Where does the file need to be placed in the tree before running the build I can see the output does have vendor folder with a couple versions of fstab, but I am not sure where it was placed in the boot images.
I would like to boot this in qemu kvm with the cuttlefish build.
Full kernel.log file here: https://pastebin.com/9MKFKeyN
Intresting part below:
[ 1.702829] init: Switching root to '/first_stage_ramdisk'
[ 1.703038] init: [libfs_mgr]ReadFstabFromDt(): failed to read fstab from dt
[ 1.703574] init: Using Android DT directory /proc/device-tree/firmware/android/
[ 1.712562] init: [libfs_mgr]Invalid ext4 superblock on '/dev/block/by-name/metadata'
[ 1.712864] traps: init[1] trap invalid opcode ip:41a6eb sp:7ffff59c93e0 error:0 in init[2f7000+200000]
[ 1.713197] init: InitFatalReboot: signal 4
[ 1.713574] init: #00 pc 000000000031b86b /init
[ 1.713626] init: Reboot ending, jumping to kernel
[ 1.713718] kvm: exiting hardware virtualization
[ 1.788726] reboot: Restarting system with command 'bootloader'
[ 1.788872] reboot: machine restart
Latest AOSP build as of 4/2/2022
buildprops
aosp/out/target/product/vsoc_x86_64/ramdisk/system/etc/ramdisk/build.prop
####################################
# from generate-common-build-props
# These properties identify this partition image.
####################################
ro.product.bootimage.brand=generic
ro.product.bootimage.device=vsoc_x86_64
ro.product.bootimage.manufacturer=Google
ro.product.bootimage.model=Cuttlefish x86_64 tv
ro.product.bootimage.name=aosp_cf_x86_64_tv
ro.bootimage.build.date=Sat Apr 2 12:06:36 CDT 2022
ro.bootimage.build.date.utc=1648919196
ro.bootimage.build.fingerprint=generic/aosp_cf_x86_64_tv/vsoc_x86_64:Tiramisu/AOSP.MASTER/me04021206:userdebug/test-keys
ro.bootimage.build.id=AOSP.MASTER
ro.bootimage.build.tags=test-keys
ro.bootimage.build.type=userdebug
ro.bootimage.build.version.incremental=eng.me.20220402.120943
ro.bootimage.build.version.release=12
ro.bootimage.build.version.release_or_codename=Tiramisu
ro.bootimage.build.version.sdk=32
# end of file
fstab.ext4
/genvol/aosp/out/target/product/vsoc_x86_64/recovery/root/first_stage_ramdisk/fstab.ext4
# Non-dynamic, boot critical partitions
/dev/block/by-name/boot /boot emmc defaults recoveryonly,slotselect,first_stage_mount,avb=boot
/dev/block/by-name/init_boot /init_boot emmc defaults recoveryonly,slotselect,first_stage_mount,avb=init_boot
/dev/block/by-name/vendor_boot /vendor_boot emmc defaults recoveryonly,slotselect
system /system erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta_system,avb_keys=/avb
system /system ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_system,avb_keys=/avb
# Add all non-dynamic partitions except system, after this comment
/dev/block/by-name/userdata /data ext4 nodev,noatime,nosuid,errors=panic latemount,wait,check,quota,formattable,fileencryption=aes-256-xts:aes-256-cts,keydirectory=/metadata/vold/metadata_encryption,checkpoint=block
/dev/block/by-name/metadata /metadata ext4 nodev,noatime,nosuid,errors=panic wait,formattable,first_stage_mount,check
/dev/block/by-name/misc /misc emmc defaults defaults
# Add all dynamic partitions except system, after this comment
odm /odm erofs ro wait,logical,first_stage_mount,slotselect,avb
odm /odm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb
product /product erofs ro wait,logical,first_stage_mount,slotselect,avb
product /product ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb
system_ext /system_ext erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta_system
system_ext /system_ext ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_system
vendor /vendor erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta
vendor /vendor ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta
vendor_dlkm /vendor_dlkm erofs ro wait,logical,first_stage_mount,slotselect,avb
vendor_dlkm /vendor_dlkm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb
odm_dlkm /odm_dlkm erofs ro wait,logical,first_stage_mount,slotselect,avb
odm_dlkm /odm_dlkm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb
system_dlkm /system_dlkm erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta
system_dlkm /system_dlkm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta
# ZRAM, SD-Card and virtiofs shares
/dev/block/zram0 none swap defaults zramsize=75%
/dev/block/vdc1 /sdcard vfat defaults recoveryonly
/devices/*/block/vdc auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata
shared /mnt/vendor/shared virtiofs nosuid,nodev,noatime nofail
I also have full kernel log and other information if it will help, Vtd and Vtx are working and all of the pci show in the IOMMU Groups.
acloud create --local-instance 1 --local-image tells me how to start troubleshooting when it fails, only after you manually build the certfile as that part of the acloud setup for instance1 cannot complete, I found that error, but have not yet fixed the source for it, that one was simple - Manually created the cert allowed it to proceed but fails at the switchroot in the boot. All the hardware and qemu all showed good.
A few points of interest as cannot add full kernel.log
Waiting for AVD(s) to boot up ...stop_cvd I 04-02 17:33:50 137759 137759 main.cc:162] Successfully stopped device cvd-1: 0.0.0.0:6520
Fail! (453s)
Total time: (453s)
Device summary:
Fail in:
Cannot create cuttlefish instance: Device did not boot within 450 secs. Stderr:
The following files contain useful debugging information:
Serial console is disabled; use -console=true to enable it.
Kernel log: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/kernel.log
Logcat output: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/logs/logcat
Launcher log: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/logs/launcher.log
Instance configuration: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/cuttlefish_config.json
Instance environment: /tmp/acloud_cvd_temp/local-instance-1/.cuttlefish.sh
Failed to read a complete exit code, read 0 bytes only instead of the expected 4
VIRTUAL_DEVICE_BOOT_FAILED
launch_cvd E 04-02 17:33:50 115944 115944 main.cc:252] run_cvd returned 10
For more detail: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/launcher.log
Encountered the following errors:
Cannot create cuttlefish instance: Device did not boot within 450 secs. Stderr:
The following files contain useful debugging information:
Serial console is disabled; use -console=true to enable it.
Kernel log: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/kernel.log
Logcat output: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/logs/logcat
Launcher log: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/logs/launcher.log
Instance configuration: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/instances/cvd-1/cuttlefish_config.json
Instance environment: /tmp/acloud_cvd_temp/local-instance-1/.cuttlefish.sh
Failed to read a complete exit code, read 0 bytes only instead of the expected 4
VIRTUAL_DEVICE_BOOT_FAILED
launch_cvd E 04-02 17:33:50 115944 115944 main.cc:252] run_cvd returned 10
For more detail: /tmp/acloud_cvd_temp/local-instance-1/cuttlefish_runtime/launcher.log
If you have any question or need acloud team support, please feel free to contact us by email at buganizer-system+419709#google.com.
Line 227 of kernel log: [ 0.318334] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug

Related

Android init service error invalid keyword 'u:object_r:system_file:s0

I want to run a service on few tablets (VONINO NAVO P) that they will serve as a photo frame for digital ads.
What i'm trying to achieve is to run some commands at boot and i'm stuck.
I have created digitalads.rc in system/etc/init which will execute /system/bin/digitalads.sh from where i need to run some commands like:
svc power stayon true
settings put system screen_brightness 255
pm disable com.android.systemui
settings put system screen_off_timeout 999999999
settings put system accelerometer_rotation 0
settings put global airplane_mode_on 0
svc bluetooth disable
monkey -p my.app -c android.intent.category.LAUNCHER 1
and some other custom commands that they will update the contents of media files
my .rc file:
tulip-f708:/ # cat /system/etc/init/digitalads.rc
service digitalads /system/bin/digitalads.sh
disabled
user root
group root
u:object_r:system_file:s0
on property:sys.boot_completed=1
start digitalads
dmesg output
tulip-f708:/ # dmesg | grep digitalads
[ 6.512868] init: /system/etc/init/digitalads.rc: 5: invalid keyword 'u:object_r:system_file:s0'
[ 6.522694] init: (Parsing /system/etc/init/digitalads.rc took 0.01s.)
[ 44.546434] init: Service digitalads does not have a SELinux domain defined.
SElinux output
tulip-f708:/ # getenforce
Enforcing
tulip-f708:/ # setenforce 0
tulip-f708:/ # getenforce
Permissive
other services run under u:object_r:system_file:s0
tulip-f708:/ # ls -Z /system/bin/
u:object_r:system_file:s0 4d78d2ea-a631-70fb-aaa787c2b5773052.ta
u:object_r:system_file:s0 a98befed-d679-ce4a-a3c827dcd51d21ed.ta
u:object_r:system_file:s0 acpi
u:object_r:system_file:s0 am
u:object_r:system_file:s0 app_process
u:object_r:zygote_exec:s0 app_process32
u:object_r:zygote_exec:s0 app_process64
u:object_r:system_file:s0 applypatch
u:object_r:system_file:s0 appops
u:object_r:system_file:s0 appwidget
u:object_r:system_file:s0 arping
.............................
I also tried to unpack boot.img to modify init.rc but failed when put it back (bricked two of them). Not mention that to root them i had to contact the manufacturer directly...
Some hints would help me! Thx
It seems your .rc files misses the seclabel keyword. Your service declaration should look like this:
service digitalads /system/bin/digitalads.sh
disabled
user root
group root
seclabel u:object_r:system_file:s0
Edit regarding your SE Linux violation: The message says that init cannot start a program labelled with system_file. That means you have to modify the SE Linux rules. The best approach would be to add a new label specific to your service:
Identify the folder where you want to add your policy. This is somewhat specific to your setup, so I cannot give you a definite answer. Check for .te files in your source code. The core Android policies are in system/sepolicy/, but if your setup has special SE policies somewhere in devices/ or vendor/, these location would be better suited for your customization (because it makes it easier for your to update to a new Android version when your customizations are as isolated as possible).
In that folder, create a new policy file, e.g. digitalads.te. Add the following rules:
type digitalads_exec, system_file_type, exec_type, file_type;
type digitalads domain;
init_daemon_domain(digitalads)
In the same folder, there should be a file file_contexts: Add a line like
/system/bin/digitalads u:object_r:digitalads_exec:s0
(When you boot with this change, ls -Z /system/bin/digitalads should show this label.)
For the seclabel in your .rc file, replace system_file with digitalads.
(Check dmesg output and also ps -Z to verify your service has been labelled correctly.)

Script that will transfer photos from phone camera using adb

Story
I take photos and record videos with my phone camera and keep all of them on my internal storage/sdcard. I periodically back them up on my PC, so I keep these camera photos on PC storage in sync with phone storage.
For years, I've been backing up my phone camera photos to my PC in the following way:
Plug in phone into PC and allow access to phone data
Browse phone storage → DCIM → Camera
Wait several minutes for the system to load a list of ALL photos
Copy only several latest photos which haven't been backed up yet
I figured that waiting several minutes for all photos to load is an unnecessary drag so I downloaded adb platform tools. I've added the folder bin to my Path environment variable (i.e. %USERPROFILE%\Tools\adb-platform-tools_r28.0.3) so that I can seamlessly use adb and not write its full path each time.
The script
I wrote the following script for Git Bash for Windows. It is also compatible with Unix if you change the $userprofile variable. Essentially, the script pulls camera photos between two dates from phone storage to PC.
# Attach device and start deamon process
adb devices
# Initialize needed variables
userprofile=$(echo "$USERPROFILE" | tr "\\" "/") # Windows adjustments
srcFolder="//storage/06CB-C9CE/DCIM/Camera" # Remote folder
dstFolder="$userprofile/Desktop/CameraPhotos" # Local folder
lsFile="$dstFolder/camera-ls.txt"
filenameRegex="2019061[5-9]_.*" # Date from 20190615 to 20190619
# Create dst folder if it doesn't exist
mkdir -p "$dstFolder"
# 1. List contents from src folder
# 2. Filter out file names matching regex
# 3. Write these file names line by line into a ls file
adb shell ls "$srcFolder" | grep -E "$filenameRegex" > "$lsFile"
# Pull files listed in ls file from src to dst folder
while read filename; do
if [ -z "$filename" ]; then continue; fi
adb pull "$srcFolder/$filename" "$dstFolder" # adb: error: ...
done < "$lsFile"
# Clean up
rm "$lsFile"
# Inform the user
echo "Done pulling files to $dstFolder"
The problem
When I run the script (bash adb-pull-camera-photos.sh), everything runs smoothly except for the adb pull command in the while-loop. It gives the following error:
': No such file or directoryemote object '//storage/06CB-C9CE/DCIM/Camera/20190618_124656.jpg
': No such file or directoryemote object '//storage/06CB-C9CE/DCIM/Camera/20190618_204522.jpg
': No such file or directoryemote object '//storage/06CB-C9CE/DCIM/Camera/20190619_225739.jpg
I am not sure why the output is broken. Sometimes when I resize the Git Bash window some of the text goes haywire. This is the actual error text:
adb: error: failed to stat remote object '//storage/06CB-C9CE/DCIM/Camera/20190618_124656.jpg': No such file or directory
adb: error: failed to stat remote object '//storage/06CB-C9CE/DCIM/Camera/20190618_204522.jpg': No such file or directory
adb: error: failed to stat remote object '//storage/06CB-C9CE/DCIM/Camera/20190619_225739.jpg': No such file or directory
I am sure that these files exist in the specified directory on the phone. When I manually execute the failing command in bash, it succeeds with the following output:
$ adb pull "//storage/06CB-C9CE/DCIM/Camera/20190618_124656.jpg" "C:/Users/User/Desktop/CameraPhotos/"
//storage/06CB-C9CE/DCIM/Camera/20190618_124656.jpg: 1 file pulled. 15.4 MB/s (1854453 bytes in 0.115s)
The question
I can't figure out what's wrong with the script. I thought the Windows system might be causing a commotion, because I don't see the reason why the same code works when entered manually, but doesn't work when run in a script. How do I fix this error?
Additional info
Note that I had to use // in the beginning of an absolute path on Windows because Git Bash would interpret / as its own root directory (C:\Program Files\Git).
I've echoed all variables inside the script and got all the correct paths that otherwise work via manual method.
camera-ls.txt file contents
20190618_124656.jpg
20190618_204522.jpg
20190619_225739.jpg
Additional questions
Is it possible to navigate to external sdcard without using its name? I had to use /storage/06CB-C9CE/ because /sdcard/ navigates to internal storage.
Why does tr "\\" "/" give me this error: tr: warning: an unescaped backslash at end of string is not portable?
Windows batch script
Here's a .bat script that can be run by Windows Command Prompt or Windows PowerShell. No Git Bash required.
:: Start deamon of the device attached
adb devices
:: Pull camera files starting from date
set srcFolder=/storage/06CB-C9CE/DCIM/Camera
set dstFolder=%USERPROFILE%\Desktop\CameraPhotos
set lsFile=%USERPROFILE%\Desktop\CameraPhotos\camera-ls.txt
set dateRegex=2019061[5-9]_.*
mkdir %dstFolder%
adb shell ls %srcFolder% | adb shell grep %dateRegex% > %lsFile%
for /F "tokens=*" %%A in (%lsFile%) do adb pull %srcFolder%/%%A %dstFolder%
del %lsFile%
echo Done pulling files to %dstFolder%
Just edit the srcFolder to point to your phone camera folder,
plug a pattern into the dateRegex for matching the date interval and
save it as a file with .bat extension, i.e: adb-pull-camera-photos.bat.
Double-click the file and it will pull filtered photos into CameraPhotos folder on Desktop.
Keep in mind that you still need have adb for Windows on your PC.
The problem was with Windows line delimiters.
Easy fix
Just add the IFS=$'\r\n' above the loop so that the read command knows the actual line delimiter.
IFS=$'\r\n'
while read filename; do
if [ -z "$filename" ]; then continue; fi
adb pull "$srcFolder/$filename" "$dstFolder"
done < "$lsFile"
Explanation
I tried plugging the whole while-loop into the console and it failed with the same error:
$ bash adb-pull-camera-photos.sh
List of devices attached
9889db343047534336 device
tr: warning: an unescaped backslash at end of string is not portable
': No such file or directoryemote object '//storage/06CB-C9CE/DCIM/Camera/20190618_124656.jpg
': No such file or directoryemote object '//storage/06CB-C9CE/DCIM/Camera/20190618_204522.jpg
': No such file or directoryemote object '//storage/06CB-C9CE/DCIM/Camera/20190619_225739.jpg
Done pulling files to C:/Users/User/Desktop/CameraPhotos
This time I started investigating why the output was broken. I remembered that windows uses \r\n as newline, which means Carriage Return + Line Feed, (CR+LF), so some text must have been overwritten.
It was because of broken values stored inside the $filename variable.
This is the loop from the script:
while read filename; do
if [ -z "$filename" ]; then continue; fi
adb pull "$srcFolder/$filename" "$dstFolder"
done < "$lsFile"
Since each iteration of the while-loop reads a line from $lsFile in the following form:
exampleFilename.jpg\r\n
It misinterprets the newline symbols as part of the file name, so adb pull tries to read files with these whitespaces in their names, but fails and it additionally writes a broken output.
Adb Photo Sync
This might not be the answer but might be useful for others looking for android photo/files backup solution.
I use this script on my Windows with git bash. This can be easily used for Linux. A common issue with a long backup process is that it might get interrupted and you might have to restart the entire copy process from start.
This script saves you from this trouble. You can restart the script or interrupt in between but it will resume copy operation from the point it left.
Just change the rfolder => android folder, lfolder => local folder
#!/bin/sh
rfolder=sdcard/DCIM/Camera
lfolder=/f/mylocal/s8-backup/Camera
adb shell ls "$rfolder" > android.files
ls -1 "$lfolder" > local.files
rm -f update.files
touch update.files
while IFS= read -r q; do
# Remove non-printable characters (are not visible on console)
l=$(echo ${q} | sed 's/[^[:print:]]//')
# Populate files to update
if ! grep -q "$l" local.files; then
echo "$l" >> update.files
fi
done < android.files
script_dir=$(pwd)
cd $lfolder
while IFS= read -r q; do
# Remove non-printable characters (are not visible on console)
l=$(echo ${q} | sed 's/[^[:print:]]//')
echo "Get file: $l"
adb pull "$rfolder/$l"
done < "${script_dir}"/update.files

Error with repacking boot.img (Android)

I have Nexus 5 with AOSP ROM 4.4.4.
I'm trying to "pull" boot.img from the device, unpack it, edit "init.rc", repack it to boot.img and flash it to the device.
I follow many guides but none of them have the same scenario as I have:
(http://droidcore.blogspot.co.il/2012/12/how-to-edit-initrc-in-android.html and http://www.digitalinternals.com/mobile/android-mmc-mmcblk-partition-layout/259/)
The device partition is mmcblck so from ls -l /dev/block/platform/msm_sdcc.1/by-name/ I got that the boot is /dev/block/mmcblk0p19:
lrwxrwxrwx root root 1971-02-28 21:30 boot ->
/dev/block/mmcblk0p19
I created the boot.img with the command: cat /dev/block/mmcblk0p19 > /mnt/sdcard/boot.img and pull this boot.img to my pc. This boot.img is ~23 MB.
I unmkbootimg the boot.img with the tool in http://droidcore.blogspot.co.il/2012/12/how-to-edit-initrc-in-android.html and got 2 files: initramfs.cpio.gz which is ~500 KB and kernel.gz which is ~8.4 MB. The details I got are:
Kernel size 8405280
Kernel address 0x8000
Ramdisk size 498992
Ramdisk address 0x2900000
Secondary size 0
Secondary address 0xf00000
Kernel tags address 0x2700000
Flash page size 2048
Board name is ""
Command line "console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead
user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1"
Extracting kernel.gz
... Extracting initramfs.cpio.gz ...
All done.
To recompile this image, use:
mkbooting --kernel kernel.gz --ramdisk initramfs.cpio.gz --base 0x26fff00 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1' -o new_boot.img
I unpack initramfs.cpio.gz with the command: gunzip -c initramfs.cpio.gz | sudo sh -c 'cd ../ && cpio -i' (from http://www.wiki.xilinx.com/Build+and+Modify+a+Rootfs) and got many files, init.rc among them. I edited this file.
I repack initramfs.cpio.gz with the command: sh -c 'cd ../ && sudo find . | sudo cpio -H newc -o' | gzip -9 > new_initramfs.cpio.gz and got this file ~500KB.
Now I mkbootimg those 2 files with the command: ./mkbooting --kernel kernel.gz --ramdisk initramfs.cpio.gz --base 0x26fff00 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1' -o new_boot.img and I got boot.img which is ~8.5 MB
Now flash the boot to the device and the device is stuck on the first screen (not boot up)
My questions are:
What's wrong?
Is that normal that my new boot.img is only 8.5 MB instead of 23 MB (the original)?
Thank you guys!
************* I FOUND THE PROBLEM *************
THE SOLUTION IS:
I used unmkbootimg from here: http://whiteboard.ping.se/Android/Unmkbootimg
After I run unmkbootimg I got this comment:
*** WARNING ****
This image is built using NON-standard mkbootimg!
OFF_KERNEL_ADDR is 0xFD908100
OFF_RAMDISK_ADDR is 0x00200100
OFF_SECOND_ADDR is 0xFE800100
Please modify mkbootimg.c using the above values to build your image.
so I follow the instructions here: https://gist.github.com/jberkel/1087757 and now it works!!!
I can't give the answer to the first question, but if I were you I'd skip step 4&5 and verify whether the unmkbootimg/mkbootimg process is correct. Only after it's verified, I till tackle with the cpio process, and finally the init.rc editing.
For the second question, google's official boot.img is 8.64MB, so I guess there is nothing wrong with the size.
Ubuntu's abootimg worked for me. I used the update (-u) option.

Compile and run CM 10.2 on simulator (GOLDFISH)

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'

I can't create files

I'm logged into an android device via ADB wireless and I'm root. I'm in /sys/devices/platform/musb_hdrc/ trying to modify a file called mode. When I pipe something into the file, it returns without error, but the file is unmodified. And when I pipe something into a new file, I get "directory nonexistent". What's going on?
# ls -l mode
-rwxrwxrwx root root 4096 2012-11-11 14:39 mode
# cat mode
b_peripheral
# echo foobar
foobar
# echo foobar > mode
# cat mode
b_peripheral
# echo foobar > myfile
cannot create myfile: directory nonexistent
#
/sys is not a real directory with real files, it's the convenient interface to the kernel functions, exported as file system. some files are writable, but most of them are read-only and you're not supposed to create any files there yourself because, once again, it's not a real file system.

Categories

Resources