I have added device in android M for AM438x and I'm using 4.4 kernel.
I have used attached create-sdcard.sh script to create rootfs and also
attached the screen shots of boot and rootfs partation.
uEnv.txt file -
kloadaddr=0x81000010
dtbaddr=0x87000010
load_kernel=fatload mmc 0 ${kloadaddr} zImage
load_dtb=fatload mmc 0 ${dtbaddr} am43x-epos-evm.dtb
set_bootargs=setenv bootargs console=ttyO0,115200n8
androidboot.console=ttyO0 mem=256M root=/dev/mmcblk0p2 rw rootwait ro
enforcing=0 androidboot.selinux=permissive
but I'm facing issue related to selinux,
i think selinux is not allowing to init process to read "mmcblk0p2" and
"file_contexts". it shows the files are "unlabele0".
please someone help me to solve this issue.
1.869693] Creating 10 MTD partitions on "8000000.nand":
[ 1.875398] 0x000000000000-0x000000040000 : "NAND.SPL"
[ 1.888116] 0x000000040000-0x000000080000 : "NAND.SPL.backup1"
[ 1.898361] 0x000000080000-0x0000000c0000 : "NAND.SPL.backup2"
[ 1.909208] 0x0000000c0000-0x000000100000 : "NAND.SPL.backup3"
[ 1.920761] 0x000000100000-0x000000180000 : "NAND.u-boot-spl-os"
[ 1.930615] mmc0: host does not support reading read-only switch,
assuming write-enable
[ 1.940006] 0x000000180000-0x000000280000 : "NAND.u-boot"
[ 1.947788] mmc0: new high speed SDHC card at address 0007
[ 1.957652] 0x000000280000-0x0000002c0000 : "NAND.u-boot-env"
[ 1.966909] mmcblk0: mmc0:0007 SS08G 7.21 GiB
[ 1.975629] 0x0000002c0000-0x000000300000 : "NAND.u-boot-env.backup1"
[ 1.986038] mmcblk0: p1 p2
[ 1.996293] 0x000000300000-0x000000a00000 : "NAND.kernel"
[ 2.006651] 0x000000a00000-0x000020000000 : "NAND.file-system"
[ 2.119007] omap_i2c 44e0b000.i2c: bus 0 rev0.12 at 100 kHz
[ 2.128429] omap_i2c 4819c000.i2c: bus 2 rev0.12 at 100 kHz
[ 2.136651] hctosys: unable to open rtc device (rtc0)
[ 2.142093] sr_init: No PMIC hook to init smartreflex
[ 2.147676] sr_init: platform driver register failed for SR
[ 2.178213] vbat: disabling
[ 2.181427] v1_0bat: disabling
[ 2.185679] v1_8bat: disabling
[ 2.235844] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data
mode. Opts: (null)
[ 2.244745] VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 2.255998] devtmpfs: mounted
[ 2.260344] Freeing unused kernel memory: 480K (c096a000 - c09e2000)
[ 2.267039] This architecture does not have kernel memory protection.
[ 2.327045] init: init started!
[ 2.359565] SELinux: Android master kernel running Android M policy in
compatibility mode.
[ 2.460124] audit: type=1403 audit(2.450:2): policy loaded
auid=4294967295 ses=4294967295
[ 2.470869] audit: type=1404 audit(2.460:3): enforcing=1 old_enforcing=0
auid=4294967295 ses=4294967295
[ 2.482958] init: (Initializing SELinux enforcing took 0.15s.)
[ 2.489408] audit: type=1400 audit(2.470:4): avc: denied { read } for
pid=1 comm="init" name="selinux_version" dev="mmcblk0p2" ino=27
scontext=u:r:kernel:s0 tcontext=u:object_r:unlabele0
[ 2.514619] audit: type=1400 audit(2.500:5): avc: denied { read } for
pid=1 comm="init" name="file_contexts" dev="mmcblk0p2" ino=1475
scontext=u:r:kernel:s0 tcontext=u:object_r:unlabele0
[ 2.535412] init: selinux_android_file_context_handle: Error getting
file context handle (Permission denied)
[ 2.546252] audit: type=1400 audit(2.530:6): avc: denied { execute }
for pid=1 comm="init" name="init" dev="mmcblk0p2" ino=15
scontext=u:r:kernel:s0 tcontext=u:object_r:unlabeled:s0 tcl0
[ 2.566012] init: execv("/init") failed: Permission denied
[ 2.571955] init: Security failure; rebooting into recovery mode...
[ 4.285521] sysrq: SysRq : Emergency Remount R/O
[ 4.301170] reboot: Restarting system with command 'recovery'
Thanks,
Mantesh
--
--
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting
---
You received this message because you are subscribed to the Google Groups
"android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
#!/bin/bash
# Authors:
# LT Thomas <[email protected]>
# Chase Maupin
# Franklin Cooper Jr.
# Jacob Stiffler <[email protected]>
#
# create-sdcard.sh v0.3
# This distribution contains contributions or derivatives under copyright
# as follows:
#
# Copyright (c) 2017, Texas Instruments Incorporated
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# - Neither the name of Texas Instruments nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Force locale language to be set to English. This avoids issues when doing
# text and string processing.
export LANG=C
# Determine the absolute path to the executable
# EXE will have the PWD removed so we can concatenate with the PWD safely
PWD=`pwd`
EXE=`echo $0 | sed s=$PWD==`
EXEPATH="$PWD"/"$EXE"
clear
cat << EOM
################################################################################
This script will create a bootable SD card from custom or pre-built binaries.
The script must be run with root permissions and from the bin directory of
the SDK
Example:
$ sudo ./create-sdcard.sh
Formatting can be skipped if the SD card is already formatted and
partitioned properly.
################################################################################
EOM
AMIROOT=`whoami | awk {'print $1'}`
if [ "$AMIROOT" != "root" ] ; then
echo " **** Error *** must run script with sudo"
echo ""
exit
fi
THEPWD=$EXEPATH
PARSEPATH=`echo $THEPWD | grep -o '.*am57xx_Android_SDK/'`
if [ "$PARSEPATH" != "" ] ; then
PATHVALID=1
else
PATHVALID=0
fi
#Precentage function
untar_progress ()
{
TARBALL=$1;
DIRECTPATH=$2;
BLOCKING_FACTOR=$(($(xz --robot --list ${TARBALL} | grep 'totals' | awk '{print $5}') / 51200 + 1));
tar --blocking-factor=${BLOCKING_FACTOR} --checkpoint=1 --checkpoint-action='ttyout=Written %u% \r' -Jxf ${TARBALL} -C ${DIRECTPATH}
}
tail_str() {
local n=$1
local str="$2"
local prfx=""
[ $n -gt ${#str} ] || prfx="..."
echo "${prfx}${str:${#str}<$n?0:-$n}"
}
#copy/paste programs
cp_progress ()
{
CURRENTSIZE=0
while [ $CURRENTSIZE -lt $TOTALSIZE ]
do
TOTALSIZE=$1;
TOHERE=$2;
CURRENTSIZE=`sudo du -c $TOHERE | grep total | awk {'print $1'}`
echo -e -n "$CURRENTSIZE / $TOTALSIZE copied \r"
sleep 1
done
}
continue_or_escape() {
ENTERCORRECTLY=0
while [ $ENTERCORRECTLY -ne 1 ]
do
read -p 'Would you like to continue? [y/n] : ' EXITQ
echo ""
echo " "
ENTERCORRECTLY=1
case $EXITQ in
"y") ;;
"n") exit;;
*) echo "Please enter y or n";ENTERCORRECTLY=0;;
esac
done
}
check_for_sdcards()
{
# find the avaible SD cards
ROOTDRIVE=`mount | grep 'on / ' | awk {'print $1'} | cut -c6-8`
PARTITION_TEST=`cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n ''`
if [ "$PARTITION_TEST" = "" ]; then
echo -e "Please insert a SD card to continue\n"
while [ "$PARTITION_TEST" = "" ]; do
read -p "Type 'y' to re-detect the SD card or 'n' to exit the script: " REPLY
if [ "$REPLY" = 'n' ]; then
exit 1
fi
ROOTDRIVE=`mount | grep 'on / ' | awk {'print $1'} | cut -c6-8`
PARTITION_TEST=`cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n ''`
done
fi
}
# find the avaible SD cards
ROOTDRIVE=`mount | grep 'on / ' | awk {'print $1'} | cut -c6-9`
if [ "$ROOTDRIVE" = "root" ]; then
ROOTDRIVE=`readlink /dev/root | cut -c1-3`
else
ROOTDRIVE=`echo $ROOTDRIVE | cut -c1-3`
fi
PARTITION_TEST=`cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n ''`
# Check for available mounts
check_for_sdcards
echo -e "\nAvailable Drives to write images to: \n"
echo "# major minor size name "
cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n ''
echo " "
DEVICEDRIVENUMBER=
while true;
do
read -p 'Enter Device Number or 'n' to exit: ' DEVICEDRIVENUMBER
echo " "
if [ "$DEVICEDRIVENUMBER" = 'n' ]; then
exit 1
fi
if [ "$DEVICEDRIVENUMBER" = "" ]; then
# Check to see if there are any changes
check_for_sdcards
echo -e "These are the Drives available to write images to:"
echo "# major minor size name "
cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n ''
echo " "
continue
fi
DEVICEDRIVENAME=`cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n '' | grep "${DEVICEDRIVENUMBER}:" | awk '{print $5}'`
if [ -n "$DEVICEDRIVENAME" ]
then
DRIVE=/dev/$DEVICEDRIVENAME
DEVICESIZE=`cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n '' | grep "${DEVICEDRIVENUMBER}:" | awk '{print $4}'`
break
else
echo -e "Invalid selection!"
# Check to see if there are any changes
check_for_sdcards
echo -e "These are the only Drives available to write images to: \n"
echo "# major minor size name "
cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<sd.\>\|\<mmcblk.\>' | grep -n ''
echo " "
fi
done
echo "$DEVICEDRIVENAME was selected"
#Check the size of disk to make sure its under 16GB
if [ $DEVICESIZE -gt 17000000 ] ; then
cat << EOM
################################################################################
**********WARNING**********
Selected Device is greater then 16GB
Continuing past this point will erase data from device
Double check that this is the correct SD Card
################################################################################
EOM
ENTERCORRECTLY=0
while [ $ENTERCORRECTLY -ne 1 ]
do
read -p 'Would you like to continue [y/n] : ' SIZECHECK
echo ""
echo " "
ENTERCORRECTLY=1
case $SIZECHECK in
"y") ;;
"n") exit;;
*) echo "Please enter y or n";ENTERCORRECTLY=0;;
esac
echo ""
done
fi
echo ""
DRIVE=/dev/$DEVICEDRIVENAME
NUM_OF_DRIVES=`df | grep -c $DEVICEDRIVENAME`
# This if statement will determine if we have a mounted sdX or mmcblkX device.
# If it is mmcblkX, then we need to set an extra char in the partition names, 'p',
# to account for /dev/mmcblkXpY labled partitions.
if [[ ${DEVICEDRIVENAME} =~ ^sd. ]]; then
echo "$DRIVE is an sdx device"
P=''
else
echo "$DRIVE is an mmcblkx device"
P='p'
fi
if [ "$NUM_OF_DRIVES" != "0" ]; then
echo "Unmounting the $DEVICEDRIVENAME drives"
for ((c=1; c<="$NUM_OF_DRIVES"; c++ ))
do
unmounted=`df | grep '\<'$DEVICEDRIVENAME$P$c'\>' | awk '{print $1}'`
if [ -n "$unmounted" ]
then
echo " unmounted ${DRIVE}$P$c"
sudo umount -f ${DRIVE}$P$c
fi
done
fi
# Refresh this variable as the device may not be mounted at script instantiation time
# This will always return one more then needed
NUM_OF_PARTS=`cat /proc/partitions | grep -v $ROOTDRIVE | grep -c $DEVICEDRIVENAME`
for ((c=1; c<"$NUM_OF_PARTS"; c++ ))
do
SIZE=`cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<'$DEVICEDRIVENAME$P$c'\>' | awk '{print $3}'`
echo "Current size of $DEVICEDRIVENAME$P$c $SIZE bytes"
done
# check to see if the device is already partitioned
for (( c=1; c<5; c++ ))
do
eval "SIZE$c=`cat /proc/partitions | grep -v $ROOTDRIVE | grep '\<'$DEVICEDRIVENAME$P$c'\>' | awk '{print $3}'`"
done
PARTITION="0"
if [ -n "$SIZE1" -a -n "$SIZE2" ] ; then
if [ "$SIZE1" -gt "70000" -a "$SIZE2" -gt "700000" ]
then
PARTITION=1
if [ -z "$SIZE3" -a -z "$SIZE4" ]
then
#Detected 2 partitions
PARTS=2
elif [ "$SIZE3" -gt "1000" -a -z "$SIZE4" ]
then
#Detected 3 partitions
PARTS=3
else
echo "SD Card is not correctly partitioned"
PARTITION=0
fi
fi
else
echo "SD Card is not correctly partitioned"
PARTITION=0
PARTS=0
fi
#Partition is found
if [ "$PARTITION" -eq "1" ]
then
cat << EOM
################################################################################
Detected device has $PARTS partitions already
Re-partitioning will format the drive with 2 partitions
################################################################################
EOM
ENTERCORRECTLY=0
while [ $ENTERCORRECTLY -ne 1 ]
do
read -p 'Would you like to re-partition the drive anyways [y/n] : ' CASEPARTITION
echo ""
echo " "
ENTERCORRECTLY=1
case $CASEPARTITION in
"y") echo "Now partitioning $DEVICEDRIVENAME ...";PARTITION=0;;
"n") echo "Skipping partitioning";;
*) echo "Please enter y or n";ENTERCORRECTLY=0;;
esac
echo ""
done
fi
#Partition is not found, format 2 partitions
if [ "$PARTITION" -eq "0" ]
then
cat << EOM
################################################################################
****WARNING**** continuing will erase all data on $DEVICEDRIVENAME
################################################################################
EOM
continue_or_escape
# Set the PARTS value as well
PARTS=2
cat << EOM
################################################################################
Now making 2 partitions
################################################################################
EOM
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
parted -s $DRIVE mklabel msdos
parted -s $DRIVE unit cyl mkpart primary fat32 -- 0 9
parted -s $DRIVE set 1 boot on
parted -s $DRIVE unit cyl mkpart primary ext2 -- 9 -2
cat << EOM
################################################################################
Partitioning Boot
################################################################################
EOM
mkfs.vfat -F 32 -n "boot" ${DRIVE}${P}1
cat << EOM
################################################################################
Partitioning rootfs
################################################################################
EOM
mkfs.ext4 -L "rootfs" ${DRIVE}${P}2
sync
sync
INSTALLSTARTHERE=n
fi
#Break between partitioning and installing file system
cat << EOM
################################################################################
Partitioning is now done
Continue to install filesystem or select 'n' to safe exit
**Warning** Continuing will erase files any files in the partitions
################################################################################
EOM
continue_or_escape
#Add directories for images
export START_DIR=$PWD
export PATH_TO_TMP_DIR=$START_DIR/tmp
mkdir $PATH_TO_TMP_DIR
export PATH_TO_SDBOOT=$PATH_TO_TMP_DIR/boot
export PATH_TO_SDROOTFS=$PATH_TO_TMP_DIR/rootfs
echo " "
echo "Mount the partitions "
mkdir $PATH_TO_SDBOOT
mkdir $PATH_TO_SDROOTFS
sudo mount -t vfat ${DRIVE}${P}1 $PATH_TO_SDBOOT
sudo mount -t ext4 ${DRIVE}${P}2 $PATH_TO_SDROOTFS
echo " "
echo "Emptying partitions "
echo " "
sudo rm -rf $PATH_TO_SDBOOT/*
sudo rm -rf $PATH_TO_SDROOTFS/*
echo ""
echo "Syncing...."
echo ""
sync
sync
sync
#check that in the right directory
THEEVMSDK=`echo $PARSEPATH | grep -o 'am57xx_Android_SDK'`
if [ $PATHVALID -eq 1 ]; then
echo "now installing: $THEEVMSDK"
else
echo "no SDK PATH found"
ENTERCORRECTLY=0
while [ $ENTERCORRECTLY -ne 1 ]
do
read -e -p 'Enter path to SDK : ' SDKFILEPATH
echo ""
ENTERCORRECTLY=1
if [ -d $SDKFILEPATH ]
then
echo "Directory exists"
echo ""
PARSEPATH=`echo $SDKFILEPATH | grep -o '.*am57xx_Android_SDK/'`
#echo $PARSEPATH
if [ "$PARSEPATH" != "" ] ; then
PATHVALID=1
else
PATHVALID=0
fi
#echo $PATHVALID
if [ $PATHVALID -eq 1 ] ; then
THEEVMSDK=`echo $SDKFILEPATH | grep -o 'am57xx_Android_SDK'`
echo "Is this the correct SDK: $THEEVMSDK"
echo ""
read -p 'Is this correct? [y/n] : ' ISRIGHTPATH
case $ISRIGHTPATH in
"y") ;;
"n") ENTERCORRECTLY=0;;
*) echo "Please enter y or n";ENTERCORRECTLY=0;;
esac
else
echo "Invalid SDK path make sure to include ti-sdk-xxxx"
ENTERCORRECTLY=0
fi
else
echo "Invalid path make sure to include complete path"
ENTERCORRECTLY=0
fi
done
fi
#check that files are in SDK
BOOTFILEPATH="$PARSEPATH/board-support/prebuilt-images"
MLO=( `ls $BOOTFILEPATH | grep MLO | awk {'print $1'}` )
BOOTIMG=( `ls $BOOTFILEPATH | grep u-boot | grep .img | awk {'print $1'}` )
BOOTUENV=( `ls $BOOTFILEPATH | grep uEnv.txt | awk {'print $1'}` )
KERNELIMAGE=( `ls $BOOTFILEPATH | grep [uz]Image | awk {'print $1'}` )
DTBDIR="$BOOTFILEPATH"
#RAMDISKIMG=( `ls $BOOTFILEPATH | grep 'ramdisk.*\.img' | awk {'print $1'}` )
#SYSTEMIMG=( `ls $BOOTFILEPATH | grep 'system.*\.img' | awk {'print $1'}` )
#USERDATAIMG=( `ls $BOOTFILEPATH | grep 'userdata.*\.img' | awk {'print $1'}` )
RAMDISKIMG="$BOOTFILEPATH/ramdisk.img"
SYSTEMIMG="$BOOTFILEPATH/system.img"
USERDATAIMG="$BOOTFILEPATH/userdata.img"
N=40
echo
echo "0. BOOTFILEPATH = $(tail_str $N $BOOTFILEPATH)"
echo "1. MLO = $(tail_str $N $MLO)"
echo "2. BOOTIMG = $(tail_str $N $BOOTIMG)"
echo "3. BOOTUENV = $(tail_str $N $BOOTUENV)"
echo "4. KERNELIMAGE = $(tail_str $N $KERNELIMAGE)"
echo "5. DTBDIR = $(tail_str $N $DTBDIR)"
for dtb in $DTBDIR/*.dtb
do
echo " * ${dtb##*/}"
done
echo "6. RAMDISKIMG = $(tail_str $N $RAMDISKIMG)"
echo "7. SYSTEMIMG = $(tail_str $N $SYSTEMIMG)"
echo "8. USERDATAIMG = $(tail_str $N $USERDATAIMG)"
echo; echo
continue_or_escape
cat << EOM
################################################################################
Copying files now... will take minutes
################################################################################
Copying boot partition
EOM
echo ""
#copy boot files out of board support
if [ "$MLO" != "" ] ; then
cp $BOOTFILEPATH/$MLO $PATH_TO_SDBOOT/MLO
echo "MLO copied"
else
echo "MLO file not found"
fi
echo ""
echo ""
if [ "$BOOTIMG" != "" ] ; then
cp $BOOTFILEPATH/$BOOTIMG $PATH_TO_SDBOOT/u-boot.img
echo "u-boot.img copied"
elif [ "$BOOTBIN" != "" ] ; then
cp $BOOTFILEPATH/$BOOTBIN $PATH_TO_SDBOOT/u-boot.bin
echo "u-boot.bin copied"
else
echo "No U-Boot file found"
fi
echo ""
if [ "$BOOTUENV" != "" ] ; then
cp $BOOTFILEPATH/$BOOTUENV $PATH_TO_SDBOOT/uEnv.txt
echo "uEnv.txt copied"
fi
echo ""
#copy kernel image out of board support
if [ "$KERNELIMAGE" != "" ] ; then
cp $BOOTFILEPATH/$KERNELIMAGE $PATH_TO_SDBOOT/zImage
echo "Kernel Image copied"
else
echo "Kernel Image not found"
fi
echo ""
#copy DTBs out of board support
if [ "$DTBDIR" != "" ] ; then
cp $DTBDIR/*.dtb $PATH_TO_SDBOOT/
echo "DTBs copied"
else
echo "DTBs not found"
fi
echo ""
$PARSEPATH/bin/extract-rootfs.sh \
-o "$PATH_TO_SDROOTFS" \
-r $RAMDISKIMG \
-s $SYSTEMIMG \
-d $USERDATAIMG
echo ""
sync
echo " "
echo "Un-mount the partitions "
sudo umount -f $PATH_TO_SDBOOT
sudo umount -f $PATH_TO_SDROOTFS
echo " "
echo "Remove created temp directories "
sudo rm -rf $PATH_TO_TMP_DIR
sudo rm -rf $PATH_TO_SDROOTFS
sudo rm -rf $PATH_TO_SDBOOT
echo " "
echo "Operation Finished"
echo " "