[SOURCE] sgdisk and gptfdisk for android - Barnes & Noble Nook Tablet

Well for today here is the next part of the puzzle. My recovery uses sgdisk over parted - well why? because its newer, it is scriptable from the shell, and does not have annoying msftres tags on my partitions and whats more because I can
Build a static sgdisk so that we can manipulate GPT partitions on the Nook
via a script
- check the existing parted - its not OK, scripted does not work
- try updated parted-3.1 - I am not able to build a fully static executable,
but the program works fine for manipulating Nook partitions on the PC
# This is an approximate record of how I built sgdisk for
# my android recovery disk
# I used fedora 15 for arm running on a sheevaplug
# I suppose you could at a pinch do this even on debian or arch or ubuntu on a qemu too but I dont know how
# most of the following commands are cut and pasted from my bash history
# so you may need to read between the lines to get the directories etc
# also note that the sheevaplug is using soft float while arm7 on android
# is usually hard float
2 How I did it
started with
rpm -ivh gptfdisk-0.8.4-1.src.rpm
rpm -ivh util-linux-2.21.1-1.fc17.src.rpm
rpm -ivh popt-1.13-10.fc17.src.rpm
get those sources from fedora-17
rpmbuild -bp --nodeps popt.spec
rpmbuild -bp --nodeps util-linux.spec
rpmbuild -bp --nodeps gptfdisk-0.8.4.spec
cd ../BUILD/popt-1.13/
./configure --help
./configure
sudo yum --disablerepo=\* --enablerepo=lf15 --enablerepo=sf15 install gettext-devel
./configure
make
ls -latr
cp .libs/libpopt.a ../gptfdisk-0.8.4/
cd ../util-linux-2.21.1/
./configure
./configure --without-ncurses
cd libuuid/
make
cp src/.libs/libuuid.a ../../gptfdisk-0.8.4/
cd ../../gptfdisk-0.8.4/
vim Makefile
# I will generate a diff for this bit
sudo yum --disablerepo=\* --enablerepo=lf15 --enablerepo=sf15 install libuuid-devel
sudo yum --disablerepo=\* --enablerepo=lf15 --enablerepo=sf15 install libstdc++ libstdc++-static
sudo yum --disablerepo=\* --enablerepo=lf15 --enablerepo=sf15 install popt-devel
make clean
make gdisk sgdisk
ldd gdisk sgdisk
file sgdisk gdisk
and bang my static binaries!
THIS WORKS FOR ME, TEST IT OUT ON EMPTY USBDISKS and sparse files first
The challenge for the next guy working on this is to use ndk to build so that we can eliminate the fat static glibc & lbstdc++ from fedora 1.5MB binaries are OK for the Nook but for other devices it may be too much
http://dl.dropbox.com/u/64885133/android-recovery-disk-sgdisk.tar.bz2

Sweet man!!! Thank you so much, this will come in handy a lot.

Used these before an all praise to the op, but the db link is not working. Use http://d-h.st/users/meghd00t/?fld_id=5334#files
Don't need to be a genius to follow OPs files, but wanted to point out. Need gdisk as busybox fdisk never seems to work for me.
Thanks for making this.
Using it on the nexus 5 and used it before on the SIII i9300

Any chance to re-upload this gdisk and sgdisk static binary ?
To my surprise, finding binary of gdisk and sgdisk for Android on Internet seems to be pretty difficult. Is it possible to re-upload it, so that I can proceed with resurecting my (still rocking) Nexus 7 ?

wangdaning said:
Used these before an all praise to the op, but the db link is not working. Use http://devhost.xda-developers.com/users/meghd00t/?fld_id=5334#files
Don't need to be a genius to follow OPs files, but wanted to point out. Need gdisk as busybox fdisk never seems to work for me.
Thanks for making this.
Using it on the nexus 5 and used it before on the SIII i9300
Click to expand...
Click to collapse
@wangdaning - please provide Android binary for gdisk (sgdisk) utility.

burlik said:
@wangdaning - please provide Android binary for gdisk (sgdisk) utility.
Click to expand...
Click to collapse
Internet is bad, cannot attach to xda. I uploaded them to github here:
https://github.com/wangdaning/Static-Disk-Tools
The files are from 2012 and I have not used them for ages. I now you need to put them in the /xbin or /sbin directory and change permissions, but I cannot remember exactly.

Related

[HOW-TO] Boot Debian with X11 and wifi from SD card. (Not chroot!)

Booting Debian with X11 on the Google NexusOne
This howto can also be found on my blog.
http://www.irregular-expression.com/?p=30
Screenshots here
http://picasaweb.google.com/JairunCaloth/Debian?feat=directlink
This is a method to boot into Debian via fastboot on the nexus one from
your SD-card. This is NOT a chroot Debian image, it is honest to goodness
Debian running directly on the hardware. This is completely non destructive to
the android OS. Connectivity to the device can be provided by adbd, ssh, or
serial console. Wifi works perfectly. I have not tested bluetooth. Touchscreen
works, but needs tweaking. X11 works in framebuffer using the Debian
testing branch (squeeze). In order to get a full fledged X driver with
3D acceleration we'll need the driver from
https://www.codeaurora.org/index.php?xwinp which I haven't been able to get
to build. This doesn't mean it's broken. It just means I suck
at cross compiling .
Todo:
-Tweak settings to make X more usable.
-Find out how to use the soft keys.
-Get the CodeAurora MSM/QSD X driver working.
-Find decent method to input text.
-Test bluetooth
-Look into using the GSM radio.
-Audio
-Figure out how to configure adbd.
-Get someone who knows C and wants to hack on the recovery image to enable booting debian from there.
This how-to pulls heavily from the debian-arm install guide.
http://www.debian.org/releases/stable/arm/index.html.en
Requirements:
adb (android-sdk)
fastboot
chroot (on your phone)
sdcard with room for Debian - 2gigs seems to be sufficient for Debian + xfce.
I Had about a gig leftover. For this guide, I'm starting fresh with a 4GB sdcard
that I'm devoting completely to Debian. According to the Debian install guide,
you need at least 32MB of memory and 500MB of hard disk space. The guide
recommends at least 5GB of storage for a comfortable install. But since I'm
using the lighter XFCE4 desktop I haven't had any space issues.
http://www.debian.org/releases/stable/arm/ch03s04.html.en
1. Re size the SD card
(don't forget to backup your data before you go messing with partition tables!!)
(optional) Instead of using a partition on your main SD card, you could
simply use another sdcard and dedicate the entire thing to Debian.
Note: android didn't like me very much when I did this. I put in a
tiny (30MB) vfat partition right at the beginning of the blank sdcard
I mounted the sdcard on my Ubuntu system and used gparted to break
off 2 gigs to use for Debian. Make sure you keep the normal android
sdcard partition as the first partition otherwise android
will not be able to find it.
If you're using apps to SD or anything else like that. Debian should
probably have the last partition. I'm not 100% sure on this since I
don't use my sdcard for anything else.
2. Format the new partition.
ext2 is probably best. (least abusive on the sdcard. ext3 & 4 have
journaling which may be bad for the life of your sdcard)
I used Gparted for this part as well.
3. If you are installing from an Ubuntu or Debian desktop, install debootstrap
Code:
$ sudo apt-get install debootstrap
Users of other distros may be able to get debootstrap but I'm not sure.
4. Mount the sdcard on your desktop.
anywhere will do just remember where you put it
ex.
Code:
$ mount /dev/sde2 /mnt/android
5. debootstrap
run debootstrap
you can change to a mirror closer to you if you don't want to use the
US mirror - http://www.debian.org/misc/README.mirrors
I'm using the Debian testing release (squeeze). I had issues getting
X11 running in lenny, and have not tested sid.
(lenny is stable, squeeze is testing, and sid is unstable)
http://www.debian.org/releases/
debootstrap --arch armel --foreign <release> </path/to/debian> <mirror>
ex:
Code:
# debootstrap --arch armel --foreign squeeze /mnt/android http://ftp.us.debian.org/debian
6. debootstrap(part2)
Unmount the sdcard from your desktop.
Reboot the phone here since you've been mucking with the sdcard
file system. Android didn't like my sdcard until I did.
Code:
$ adb shell
mount the sdcard somewhere on the android file system.
look in /dev/block for the sdcard.
Typically mmcblk0p# where # is the partition number.
*note* the directory I use to mount mine does not exist under normal android.
If this is your first time you will need to create the directory.
Code:
mkdir -p /data/local/mnt
ex.
Code:
# mount -t ext2 /dev/block/mmcblk0p2 /data/local/mnt
chroot/debootstrap
Code:
# export PATH=/usr/bin:/usr/sbin:/bin:$PATH
# chroot /data/local/mnt/ /debootstrap/debootstrap --second-stage
this will take a while especially if you have a slower sdcard.
6. While that's working, now is a good time to get to work on your kernel
I used the open source android kernel 2.6.29
http://android.git.kernel.org/
Started with mahimahi_defconfig and starting customizing from there.
Things to note.
- file systems - don't forget to add support for whatever file systems
you need. Your root file system support cannot be built as a module.
- wireless driver config - You may want to change the location the
kernel looks for your wifi firmware (this is different from the
kernel module).
I stuck mine in /etc/firmware, default is /system/etc/firmware.
If you don't change this, you will have to put the firmware
in /system/etc/firmware
- wireless - Add in support for standard wifi extensions.
- networking - standard tcp/ip stuff... iptables if you want ect...
- I wasn't able to get the kernel to boot into Debian until I turned
off initramfs support.
(note. this was before I discovered the 'noinitrd' kernel
kernel cmdline option. So disabling initrd may not be required)
- If for some reason you are using ext4, it will fail to mount unless
you add in large devices and files support
- Default kernel command string - has no effect.
This gets overwritten when you boot with fastboot or make a boot.img
- Drivers - I left all the normal android drivers in.
-Changed the firmware path for wifi.
-Added in support for virtual terminal under character devices
-Enabled MSM serial support (if you don't have a serial cable
this is useless to you)
-You can build the wifi driver into the kernel if you want.
Link to the kernel config I used. Use at your own risk.
It works for me but I can't promise it's perfect or even good.
http://irregular-expression.com/tmp/config
I would love input on building a better kernel config.
If you don't want to build your own kernel, feel free to use mine http://irregular-expression.com/tmp/zImage
7. Chroot and configure Debian.
There are still some things that need configuring before we reboot into
Debian. Since fbconsole does not appear to be working, if you don't
have a serial cable you will be flying blind until Debian is fully
booted and you can connect with ssh. Since there are still things to do
before we reboot, we're going to chroot into Debian just like if we are
using a Debian chroot image.
For more information and examples of config files.
http://www.debian.org/releases/stable/arm/apds03.html.en
It's probably best to use wifi for your data on the phone for this.
If you're on Linux and connected to the same router as the phone, copy
over your resolv.conf
Code:
$ adb push /etc/resolv.conf /data/local/mnt/etc/resolv.conf
If you are not in Linux or are not connected to wifi you will need to
set up resolv.conf with something sane.
ex. from jay freeman's original Debian chroot.
Code:
$ echo 'nameserver 4.2.2.2' > /data/local/mnt/etc/resolv.conf
push wifi driver to the device
First we need to create a couple directories. Log into the phone with adb shell
Code:
$ adb shell
# mkdir -p /data/local/mnt/etc/firmware
# mkdir -p /data/local/mnt/lib/modules/2.6.29-droid-debian/kernel/drivers/bcm4329
# exit
Upload wifi kernel module and firmware. If you're using my prebuilt kernel, grab this one. http://irregular-expression.com/tmp/bcm4329.ko
Code:
$ adb push <kernelroot>/drivers/net/wireless/bcm4329/bcm4329.ko /data/local/mnt/lib/modules/2.6.29-droid-debian/kernel/drivers/bcm4329/
copy /system/etc/firmware/fw_bcm4329.bin to wherever you
specified in the kernel config.
Code:
# cp /system/etc/firmware/fw_bcm4329.bin /data/local/mnt/etc/firmware/
Setup environment variables, copy over adbd, and other stuff needed to
make things work. This should all be run from within an adb shell
Code:
# cp /sbin/adbd /data/local/mnt/sbin/adbd
# sysctl -w net.ipv4.ip_forward=1
# export PATH=/usr/bin:/usr/sbin:/bin:$PATH
# export TERM=linux
# export HOME=/root
Next chroot and setup mount points
Code:
# chroot /data/local/mnt /bin/bash
# mount -t devpts devpts /dev/pts
# mount -t proc proc /proc
# mount -t sysfs sysfs /sys
Welcome to Debian chroot that we all know and love.
Lets finish configuring this thing.
Configure adbd to run on boot and create a symlink so adbd can find bash.
Edit /etc/rc.local. Add adbd before exit 0
#add this to /etc/rc.local
Code:
/sbin/adbd &
Code:
# mkdir -p /system/bin/
# ln -s /bin/bash /system/bin/sh
Now we need to be able to install packages
don't forget if you are not using squeeze to change it here
Code:
# echo 'deb [url]http://ftp.us.debian.org/debian[/url] squeeze main' >> /etc/apt/sources.list
# apt-get update
You should see aptitude updating it's package list.
Install some needed packages
Code:
# apt-get install wpasupplicant wireless-tools udev ssh
Other packages
All up to your choice. Things like text editors, X, ect...
some suggested packages
Code:
# apt-get install locales vi
Wifi driver
When you try to load the wifi module, Linux will complain about not
being able to parse modprobe.d. To fix this run depmod. If it complains
a directory doesn't exist then create it.
Code:
# depmod -a
Edit /etc/modules and add the bcm4329 module
Code:
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
bcm4329
Setup fstab - critical: don't forget to configure the root file system
or your system won't boot. If you like, mount your vfat sdcard partition
here too. Don't forget to mkdir for the mount point.
*note* after boot the memory card is located at /dev/mmcblk0p#.
Here is my /etc/fstab
Code:
# /etc/fstab: static file system information.
#
# file system mount point type options dump pass
/dev/mmcblk0p2 / ext2 defaults 1 1
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /media/sdcard vfat defaults 0 0
configure network
These two files will be tuned to what you need.
Here are a couple examples.
/etc/network/interfaces
Code:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf
/etc/wpa_supplicant.conf
Code:
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="myOpenNetwork"
scan_ssid=1
key_mgmt=NONE
}
network={
ssid="MyHomeNetwork"
scan_ssid=1
key_mgmt=WPA-PSK
psk="MyWifiPassword"
}
network={
ssid="MyFriendsWifi"
scan_ssid=1
key_mgmt=WPA-PSK
psk="MyFriendsWifiPassword"
}
SSH
If you want ssh to start on boot run this command.
*note* You will probably want to set a static IP address if you plan on accessing debian through ssh.
Code:
# update-rc.d ssh defaults
inittab
no need for getty so comment it out in /etc/inittab
if you have a serial cable, configure it here. something like this.
Code:
T0:23:respawn:/sbin/getty -L ttyMSM0 115200 linux
hostname
configure your system's hostname - you can set this to whatever you like
Code:
# echo DebianHostName > /etc/hostname
Set root password
Code:
# passwd
# useradd -m -G audio,dialout,floppy,video,staff username
Add user account
Code:
# useradd -m -G audio,dialout,floppy,video,staff yourusername -s /bin/bash
# passwd yourusername
8. Almost there!
Double check your configs and have your kernel handy.
The next step is to boot into Debian.
9. Boot Debian
put the device into fastboot mode
Code:
$ adb reboot bootloader
the '-c' flag specifies arguments to pass to the kernel for boot.
This is probably the bare minimum.
Format is "fastboot -c 'kernelcmdline' boot zImage"
Code:
$ fastboot -c 'root=/dev/mmcblk0p2 rw rootfs=ext2 init=/sbin/init rootwait noinitrd' boot zImage
Wait just a few minutes. DHCP is probably the longest part of this.
10. Connect via ADB.
If everything went well you should be able to log into the
phone via adb. adb push and pull work as well.
Code:
$ adb shell
11. Install X11
For a basic X11 install. This is probably not what you want.
Code:
# apt-get install xserver-xorg
You can install whatever window manager/desktop environment you like,
I used XFCE. Most window managers likely depend on xserver-xorg so it
will get pulled in when you install.
Code:
# apt-get install xfce4
After I installed xfce4 I was able to get X on the main display by
simply running startxfce4
Code:
# startxfce4
By default Debian is configured to only allow root to startx.
If you want to be able to run X as a user edit /etc/X11/Xwrapper.config
*note* even with this I haven't been able to run X as a normal user.
Only root.
Change
Code:
allowed_users=console
to
Code:
allowed_users=anybody
Currently touchscreen is a little weird. It feels almost like using a
laptop touchpad. The mouse moves much faster then your finger and tapping for
click isn't enabled by default but two finger tap will right click. You can
also move the mouse with the trackball. Clicking the trackball registers a
click. But you have to wiggle the trackball just a tiny bit after you click to
make it register. I am going to work on tweaking the fdi policy files to
make things a little more usable.
Text entry is a bit of a pain point currently. There are several on screen
keyboards out there. One interesting one I found is called cellwriter.
The touchscreen will need to be tweaked before it will work well with
onscreen keyboards.
For other ideas on window managers and other software check out this link
http://wiki.openmoko.org/wiki/Debian
@jairuncaloth
I was just reading about how you got debian + x11 working on your nexus. I think thats awsome how you got a fully oprerational linux OS on your phone. I just had a few questions on how everything worked.
You were saying it doesn't mess with the default android OS, is there like a duel boot option to chose what OS i want to boot into. I was reading on how you have to start an ssh session to get into debian, and was just currious on some more info. I would be intrested in trying this out some time after i did a little more reading to get a better understanding of how everything was working.
If this wasn't working out after i installed, is it a pain to remove.
Thanks,
Justin
Nice post, appreciate the thoroughness.
I'm going to pour through this when I get some free time. Whenever that is
Thanks!
~enom~
jjkwasnik said:
@jairuncaloth
I was just reading about how you got debian + x11 working on your nexus. I think thats awsome how you got a fully oprerational linux OS on your phone. I just had a few questions on how everything worked.
You were saying it doesn't mess with the default android OS, is there like a duel boot option to chose what OS i want to boot into. I was reading on how you have to start an ssh session to get into debian, and was just currious on some more info. I would be intrested in trying this out some time after i did a little more reading to get a better understanding of how everything was working.
If this wasn't working out after i installed, is it a pain to remove.
Thanks,
Justin
Click to expand...
Click to collapse
Hey Justin. The reason it doesn't mess with the default android OS is when you boot, you're booting with a kernel image living on your desktop/laptop's hard disk. fastboot allows you to boot images without acctually flashing them to your phone. Debian lives on the SDcard so no flashing required.
You can also use adb to connect to debian now. It's as simple as copying over the binary from android.
Removing is as simple as rebooting. When you reboot it will be like debian was never there.
enomther said:
Nice post, appreciate the thoroughness.
I'm going to pour through this when I get some free time. Whenever that is
Thanks!
~enom~
Click to expand...
Click to collapse
I would love to hear ideas for improvements you may have
This is still pretty raw.
now my question is can those devs good with the linux kernel use this to hack into the android OS and unlock the security on the device without bricking the phone?
-Charlie
@jairuncaloth
I understand what you mean, i have used fast boot a few times. I know how to use it, just haven't used it a lot. So with using fast boot, once Debian is booted can you disconnect the usb cable. Is the kernel copied in RAM, or does it still need to talk to the kernel that resides on the PC?
I like where you are going with this, i am experienced with Linux. Not super advanced, but i know more then i think i do sometimes. I would like to try this out sometime to, but i'm very busy with work and the little free time i have gets spent before i know it. So knowing a little about it before i get my feet wet, always helps.
Thanks!!
Great news guys! Glad to see progress is being made. Can't wait to see where this goes from here!
Cheers
this is so cool, i was trying to get the chroot version to run on my nexus one the other day like i had it on my g1 but it was giving me trouble so i gave up. if proper support for the radio and the touchscreen/keyboard is created this would truly be monumental.
kudos for you man awesome job!
jjkwasnik said:
@jairuncaloth
I understand what you mean, i have used fast boot a few times. I know how to use it, just haven't used it a lot. So with using fast boot, once Debian is booted can you disconnect the usb cable. Is the kernel copied in RAM, or does it still need to talk to the kernel that resides on the PC?
I like where you are going with this, i am experienced with Linux. Not super advanced, but i know more then i think i do sometimes. I would like to try this out sometime to, but i'm very busy with work and the little free time i have gets spent before i know it. So knowing a little about it before i get my feet wet, always helps.
Thanks!!
Click to expand...
Click to collapse
Should look something like this after you run the fastboot boot command
creating boot image...
creating boot image - 2240512 bytes
downloading 'boot.img'... OKAY
booting... OKAY
At this point it's safe to pull the usb cable. If you are using adb to connect, you'll still want it though
I got the code aurora X driver to build last night. I ended up building it in debian on the phone. I couldn't get it to build against AOSP kernel headers, but it does build with the code aurora kernel headers. X won't start when you tell it to use the driver. I suspect this is because I built the driver against a different kernel then the one the system is booting on. I have not been able to get the code aurora kernel to boot yet, but I'm working on it to see if X will start with this driver and the CA kernel.
Also, I've uploaded the kernel I've been using to my blog. In case someone wants to play with this, but doesn't want to build a kernel.
http://irregular-expression.com/tmp/zImage
Can anyone post any vids for this?
Would love to have a look at this and then maybe i'll have a try at it afterwards
No videos yet.. I've got some snapshots of X running though.
http://picasaweb.google.com/JairunCaloth/Debian?feat=directlink
jairuncaloth said:
No videos yet.. I've got some snapshots of X running though.
http://picasaweb.google.com/JairunCaloth/Debian?feat=directlink
Click to expand...
Click to collapse
Thank you for the pictures, it really feels good to see this kind of progress being made. I can not wait to try this out!
looks interesting, but scary to a new guy like me..im sure i will try it though..continue the work on streamlining the process !
so how is this running? by that i mean is everything running smooth/snappy?
looks good by the way, i may try this out
JHaste said:
so how is this running? by that i mean is everything running smooth/snappy?
looks good by the way, i may try this out
Click to expand...
Click to collapse
It's fast enough for you old man!
Really though, it runs pretty smoothly. Once we work out the kinks it could even be pretty nice.
One thing you could do, if you don't mind nuking the recovery partition, is flash your debian boot image to recovery -- then you can reboot into debian with "reboot recovery" from an android root shell, or by entering the bootloader and selecting recovery.
it will be great if it is more simple.
@jairuncaloth
I love the pics man!!!
I just came up with another question with running Debian, is there any software to still make phone calls through your cell provider? Or do you just have to reboot back into android?

[Q] tf201 android/ubuntu duel boot?

i like my android for home use ,but as a IT maneger it will be nice to have linux on my prime as well. thar is any toturial that expline how to make my prime duel boot this 2 OS?
Overview
Follow this thread: Ubuntu | How-to install it on the Prime . NOTICE: developer-thread
Mainly there are 2 methods:
Flash-boot:
The thread starts with LilStevies work from Androidroot. There you have to flash the correspondent boot-kernel to start either android or linux. So far I don't know of an existing LilStevie rom with the kexec/kexecboot method (kexec: Linux as bootloader).
SDCard-existence-driven-init
Running linux with root_chooser_v1/2/3 form tux_mind which starts around thead-page 35 uses a modified init. Dualboot: with SDCard in slot -> linux | without SDCard in slot -> Android
See: Gentoo Wiki and hack-job if you are on Asus stock rom.
You can also use chroot method - but it's not dualboot.
I had method 1 running. But for me it is not working for daily useage. (reflashing s*c*s :angel
Now i will use the SDCard-existence-driven-init
I can't use the posted boot-blob because I'm not on the Asus stock kernel so Android starts but many processes crash so that it is not useable. I use the Energy-Rom with the Clemsyn-kernel. (Prime is unlocked, nvflash-activated and rooted)
Be warned: You could damage/ brick your device following the instructions. Backup all!! A whole nvflash backup is reccomended. Be carful. Use your brain. I'm not responsible for any damages.
Up to now I tested my own 'unchanged' fastboot boot-blob:
Enter APX-Mode: put in USB cable + hold [Vol up]+[Power] (until vibrating, screen stays black)
Code:
$ sudo wheelie -r --blob blob.bin
$ sudo nvflash -r --read 6 blobNv.LNX
$ sudo nvflash -r --go
Unpack blob:
Code:
$ abootimg -x blobNv.LNX
repack blob (be sure you have blobpack for TF201 i.e. from CM10 repo):
Code:
$ abootimg --create testNv.LNX -k zImage -r initrd.gz -f bootimg.cfg
$ blobpackTF201 testFb.blob LNX testNv.LNX
start into fastboot-mode: put in USB cable [Vol down]+[Power] (until you can choose fastboot/USB symbol)
Code:
$ fastboot -i 0x0b05 flash boot testFb.blob
$ fastboot -i 0x0b05 reboot
The blob flashes well - I can see the blue progerss-bar. By the way: this produces a backup blob of the bootpartition which you can reflash via fastboot to start android if sth went wrong.
Now I need to insert the root_chooser init into the ramdisk to get linux from SDCard started...
I got a half working root_chooser. It starts android but not linux.
Here is what I did to modify the boot-loader with Clemsyn kernel and the modified init from tux_mind:
At first I read the LNX patition from the TF201 (unlocked, nvflash-able/wheelie, rooted):
Boot into APX-mode:
Code:
$ sudo bin/wheelie -r --blob bin/blob.bin
$ sudo bin/nvflash -r --read 6 blobNv.LNX
$ sudo bin/nvflash -r --go
Unpack the blob:
Code:
$ abootimg -x blobNv.LNX
You will get bootimg.cfg, initrd.img and zImage.
Now unpack the initial ramdisk:
Code:
$ mkdir ramdisk
$ cd ramdisk
$ gzip -dc ../initrd.img | cpio -i
Clone tux_minds data and copy your extracted custom rom ramdisk to newroot:
Code:
$ cd ..
$ git clone https://github.com/tux-mind/tf201-dev.git
$ rm -r tf201-dev/initramfs/newroot/*
$ cp -r ramdisk/* tf201-dev/initramfs/newroot/
[I][SIZE="2"]#edit 22 feb 2013[/SIZE][/I]
$ cd tf201-dev/initramfs
$ mkdir data && mkdir dev && mkdir sys
$ cd ../../..
[I][SIZE="2"]#edit end[/SIZE][/I]
OPTIONAL start compile root_chooser/init via crosscompile
Change the compiler in Makefile. I use Ubuntu with arm-linux-gnueabi-gcc (maybe it would be better to use arm-linux-gnueabihf-gcc) from the repo for crosscompiling:
Edit Makefile in tf201-dev/root_chooser:
Code:
#--Head-------------------- snip
CC=arm-linux-gnueabi-gcc
LD=arm-linux-gnueabi-ld
#CC=arm-unknown-linux-gnueabi-gcc
#LD=arm-unknown-linux-gnueabi-ld
#-------------------------- snap
Now compile and copy it to the initramfs:
Code:
$ make v2
$ cp root_chooser ../initramfs/init
OPTIONAL end
Now pack the initrd, make a blob and flash it to the TP
Code:
$ cd tf201-dev/initramfs
$ find . | cpio --create --format='newc' > ../../myinitrd
$ cd ../..
$ gzip myinitrd
$ chmod 777 myinitrd.gz
$ abootimg --create testNv.LNX -k zImage -r myinitrd.gz
$ bin/blobpackTF201 testFb.blob LNX testNv.LNX
Start into fastbootmode:
Code:
$ fastboot -i 0x0b05 flash boot testFb.blob
$ fastboot -i 0x0b05 reboot
Start into andorid open Terminal Emulator and type:
Code:
$ su
# vi /data/.boot
/dev/mmcblk1p1:/:/sbin/init
[esc] :wq
I followed this guide to set up my sdCard. That's it. Insert sdCard, reboot.
Android starts but not Linux from the sdCard. I got the following message back in android:
Code:
[I][B]FIXED[/B][SIZE="2"] see edit 22 feb 2013[/SIZE][/I]
[COLOR="Silver"]$ cat /boot_chooser.log
unable to mount /sys - No such file or directory[/COLOR]
New error message (inserted sdCard occurs boot-loops, remove sdCard to start android):
Code:
$ cat /boot_chooser.log
unable to mount /dev/mmcblk1p1 on /newroot - No such file or directory
I'm feeling so close to fire up Linux on my Transformer. Who can give me hint?
gophix said:
New error message (inserted sdCard occurs boot-loops, remove sdCard to start android):
Code:
$ cat /boot_chooser.log
unable to mount /dev/mmcblk1p1 on /newroot - No such file or directory
Click to expand...
Click to collapse
got it yeah! linux and android starting up! BUT VERY INSTABILE !!!
I had to use another sdCard and recompiled the kernel with some flags activated:
My hama 16GB class 10 doesn't seem to work well with the TP. I copied some data to the sdcard in android, there the I/O stream had several stops while copying data. Some forum members reported I/O errors in the system log (dmesg). I didn't have that errors but a variing throughput while copyint to sdCard.
The kernel I prepared this way:
Code:
downloading Clemsyn-kernel source:
$ wget https://www.dropbox.com/s/pjqd2b1edn6fiwu/tfcombofinal.zip
$ unzip tfcombofinal.zip
Get the actual kernel .config form the TP via adb and compile the kernel (I didn't patch, because I got error while compiling the kernel). I diffed my config to tux_minds and aktivated some flags.
Code:
$ adb pull /proc/config.gz
$ gzip -d config.gz
$ cp config tfcombofinal/.config
$ cd tfcombofinal
// patching should be like this:
// $ wget https://github.com/tux-mind/tf201-dev/raw/master/v2/kernel/JB15.patch
// $ patch -p1 < ../JB15.patch(v1/v2?) !!! do not patch !!!
$ make menuconfig
$ make -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
I didn't compile the modules.
After that I packed my kernel from tfcombo/arch/arm/boot/zImage into the blob ($ abootimg --create testNv.LNX -k zImage -r myinitrd.gz)
VERY INSTABILE !!! means: the linux starting kernel was compiled with hardfloat (arm-linux-gnueabihf-).Linux starts up and responds "a littel bit"; android starts up; work 5 mins and reboots.
So both are working the developer way
I will test an own armSF kernel next time (the way described in this post, up to now I run instable on armHF) and report if this makes android stable and additionally starts up linux.
The dual-boot works fine.
Look at lifeinarootshell.
The actual version root_chooser v6 starts linux (from SDcard, microSDcard, USB, loop-device, internal folder) and android with different kernels
It has a cofigurable bootloader via kexec.
Linux distributions (gentoo, ubuntu, arch linux, ...) are also available and are growing more and more in stability and performance.
gophix said:
The dual-boot works fine.
Look at lifeinarootshell.
The actual version root_chooser v6 starts linux (from SDcard, microSDcard, USB, loop-device, internal folder) and android with different kernels
It has a cofigurable bootloader via kexec.
Linux distributions (gentoo, ubuntu, arch linux, ...) are also available and are growing more and more in stability and performance.
Click to expand...
Click to collapse
Getting xorg to work on archlinux is somewhat messy at the moment. The tegra3 driver is built for an old xorg-server, and is not compatible with the new one in the archlinux repositories. I was able to make it work by recompiling xorg-server, though. I guess it would be easier if someone made an aur package with the old xorg-server.
Thank you very much gophix for your nice guide in the second post :fingers-crossed:
However, since the first attempts to get linux based distributions working on the TF201 like ubuntu or arch linux, there was not much progress anymore I feel this is somehow pitty due to the fact that the Prime is still a good and reasonable tablet. And it could be much more if there would be not these horrible restrictions set by Asus like encrypted bootloader.
But I don't want to criticise mainly in my post. Instead, I would like to promote a constructive discussion so that the TF201 receives new life
How about creating a new ubuntu image based on 14.04 since it receives long term support? Unfortunately, my knowledge is still rather limitted so far to do this by myself.
And what is your opinion, to go alternatively another way by using the xubuntu installation (13.04) developed for the TF300tg as shown here:
http://forum.xda-developers.com/showthread.php?t=2190847
As far as I know, both devices are quite similar. Or are there any good arguments to deny this idea?

[Q] USB networking. I want to VNC over usb from Ubuntu 12.04,[ working over wifi]

Well the script should be working, it is 'ettin.sh' now. To get VNC to work on separate device just change 'eth0' to 'wlan0' or whatever other interface you know how to configure, like usb maybe, in the 'init.sh' script that resides in ~/ on the images you can download from http://linuxonandroid.org/downloads/. Cool. If anyone can help with the usb configuring that would be cool.
Also on the different roms your storage might be different so just change that to what suites your environment,
BAD NEWS, After my first launch and exiting the VNC on my laptop (Ubuntu) My phones home button and a few other functions stopped working, a reboot remounts the root and system partitions and it goes back to normal essentially, I haven't noticed any adverse affects after the reboot.
Good luck.
EDIT: If you can't help me, you probably shouldn't attempt any of this.
I want to connect to backtrack over usb from Ubuntu on my laptop instead of from my phone. Is there a good way of doing this?
The thing is, I didn't chroot, I mounted the image, copied the contents of '/etc/*' and '/sbin/*' to the '*/etc' '*/sbin' dirs of the mounted image. and then mounted it's (the image's) contents to Androids rootfs '/' then I set up a little script to set up the environment and execute '/bin/bash -i init.sh' and again reset PATH to include /system/*.
Then in the init.sh script I want to set up a way to 'vnc' through' usb to backt4acks desktop. How would I do this?
EDIT: I started this script blelow, its not complete, feel free to use it however you like.
If anyone is good with bash I need help with loops in Bash or shell, ksh, or ash. So if you change it at all share those changes here. I haven't tested any of the loops, I wrote this here and need to do some reading on shell scripting, peace out.
Just NOTE that I would not execute this script yet, it is NOT YET COMPLETE.
I will be making minor changes as I learn and test things out, Also this was inspired by the autobootscrip (sp?) that the Linux on Android Installer app uses.
mintberrycrunch revision
I need a little help with the mounting part, "is there anybody out there?"
EDIT: Maybe escape '\' characters...
Maybe this will work? 'if [ ! -d "/$d" -a "$d" \!= "dev" -o "$d \!= "mnt" ]; then ' I want it to test whether the directory does not already exists in / and if it is not named dev or named mnt then mount it. Do you think this is a decent way to do it? Any suggestions?
Sorry, I still haven't tested this script yet, so if you brave and see any changes that will make it work I am not resposible. But it is getting close to when I will run it for the first time. The difference between this and the one I wrote for Kali is this should be a one stop shop so to speak for getting into a non chroot enviroment where you can access Bt's tools from Android directly. Apperently about a year ago someone was trying something similar called "debian installer" or something, I haven't tried it out so maybe that actually works, idk, I am happy with this.
LOL
LMFAO!
I just realized I don't think I needed to worry about testing if the variable $d was named 'dev' or 'mnt' because they should get skipped by already being mounted. If not I guess if it works as is, may be extra precaution.
Done! Almost ;{)-
Uhmm.... hope you can see the screenshot...
its over wifi though, I had to edit the init.sh script just eth0 to wlan0 in 2 lines, duh! where is eth0 on phone?
Check out the filesystem
Bada bing, bada doom, dare ya goes`a for ya.
V-0.021
This should support args, if your using different image or location such as external sdcard or want to mount to a different location
Notes: 'ettin.sh' [/IMAGE/LOCATION] [IMAGENAME] [MOUNT/POINT]'
1) Don't add a trailing forward slash for image location, the first argument. Doing so may conflict with the script.
2) Don't add suffix to image name ( second argument), the script uses a wild card period wild card syntax to account for .iso, .raw, or .img aswell as version numbers, so if its backtrack-v-r5.img all you need is 'backtrack'.
3) Default mount is "/data/local/mnt"
for example:
Code:
ettin.sh /storage/extSdCard/ubuntufolder ubuntu /mnt/myLinux
That ^^^ will use a ubuntu image on the external sdcard and mount it to a folder called "myLinux" within the "/mnt" directory.
The script below...
Code:
#!/system/bin/sh
# ettin.sh v-0.021, "Two heads are better than one."
# Written by 'Edge-Case' @ 'forum.xda-developers.com'
# This version is attempting to use symbolic linking to correct some issues.
## The purpose of ettin.sh is to merge a Linux system with Android
## hopefully allowing both systems to run in synch with each other.
## It is probably best to be ran on devices with multi-core processors.
##"""Notes on Backtrack and Kali Linux Distributions:
##"""1) Postgresql needs to be configured in order for metasploit to connect to
##""" the database. This might be possible within the script. Perhaps
##""" it is simply a matter of configuring SSH? I don't know.
##"""2) The Kernel needs to be patched to allow for packet injection and
##""" monitor mode for an external 'wi-fi' card as the factory hardware
##""" does not support monitor mode, at least on Samsung Galaxy SIII.
#########
# Prep ##
#########
mount -wo remount systemfs /system
mount -wo remount rootfs /
imloc=${1:-"/storage/sdcard0/backtrack"}
imname=${2:-"backtrack"}
subset=${3:-"/data/local/mnt"}
#Check for root!
if [ ! -d "$subset" ]; then mkdir "$subset"; fi
busybox mount -wo loop ${imloc}*/${imname}*.* ${subset}
check_mnt="`echo $?`"
if [ ${check_mnt} != 0 ]; then echo "Something is wrong with mounting, check the situation!" && exit; fi
##################################################
# Copy contents of special directories to image ##
##################################################
if [ ! -f "${imloc}/success.txt" ] ; then cp -ai /sbin/* ${subset}/sbin && echo "Files have been copied on `date`." > ${imloc}/success.txt; fi
if [ -e "/root/*" ]; then cp ai /root/* ${subset}/root; fi
######################################################
# Make directories needed and mount the file-system ##
######################################################
cd ${subset}
for d in `ls` ; do if [ ! -d "/${d}" ] ; then mkdir /${d} && busybox mount --rbind ${subset}/${d} /${d} ; fi ; done
busybox mount --rbind ${subset}/root /root
busybox mount --rbind ${subset}/sbin /sbin
busybox cp -rspi ${subset}/etc/* /etc # We'll try making symbolic links from the image to Android's /etc instead.
# Add any directories as needed.
###############################
# be safe before we continue ##
###############################
mount -ro remount systemfs /system
mount -ro remount rootfs /
######################################
# continue building the environment ##
######################################
export PATH="/system/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/system/xbin:/usr/games"
export TERM=linux
export HOME="/root"
#################################
# further down the rabbit hole ##
#################################
/bin/bash -i ~/init.sh
Pretty happy with it now, so far. Touch FIXED
Well, I am tethered from my phone to my laptop, running ubuntu, this is how I am on the internet, so my phone is doing that...
I ran 'ettin.sh /storage/sdcard0/ubuntu ubuntu' using V-0.022 and only had two files that needed overwriting.
The touch is working....check
adb is working...check
Everything is mounted ...check
Apps like browser and dsploit are working on the phone as usual...check
'apt-get update && apt-get upgrade'....check (over adb, no chroot, as [email protected] using bin/bash)
'which nmap' .....check ("
[email protected]:~# which nmap
/usr/bin/nmap
")
Well **** ya'll looks like this might work... I am now going to consider modifying a stock rom to support users and login that meshes with debian and its "shadow" file etc etc, also I need to work out permissions and enviroment variables...
I'm happy...
Also for pentesting distro's "modifying Android kernel" tutorials would be nice, anybody able to point me to one?

[GUIDE] Build Cyanogenmod from Source

Hi,
I have decided to write this post after reading so many different guides on my journey to build my own version of Cyanogenmod and after countless tries and hours of research I succeeded. Here's how:
You will need:
A Ubuntu box
A basic knowledge of Linux
A fast internet connection or a lot of patience.
Once you have setup your Ubuntu box either in a Virtual Machine of as a stand alone PC you will need to open a terminal, this can be done by pressing 'CTRL + ALT + T' or opening the search menu and typing "Terminal".
You should see the following:
Code:
[email protected]:~$
We will need to install all the necessary files in order to build and download Cyanogenmod, we can do this by running the following command:
Code:
sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev openjdk-7-jdk openjdk-7-jre
As many Linux users have more than one version of Java installed we will need to set the the version we just installed as our default version.
Code:
sudo update-alternatives --config java
sudo update-alternatives --config javac
If by any chance you have a 64-bit version of Ubuntu installed we will require some extra files, if not please skip this command.
Code:
sudo apt-get install g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
We will now for simplicity's sake need to create the following directories in your home folder. These directories will host our build.
Code:
mkdir -p ~/bin
mkdir -p ~/android/system
Once you have setup everything correctly we will now to download the Cyanogenmod source code of which we are going to use the 'Repo' utility. This utility is an automated tool for GitHub cloning. We can download this and set the correct permissions by running the following commands.
Code:
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
To continue with download the source code we will now initialize the GitHub repository that holds Cyanogenmod. We are going to need to specify the repository with -u and the branch with -b. Here I am going to download the latest available version of Cyanagenmod 13.0.
Code:
cd ~/android/system/
~/bin/repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0
And to finally start downloading the source:
Code:
~/bin/repo sync -c -f -j8
Where:
-c Download the current version instead of all history.
-F Forces the connection to continue even if a connection error occurs.
-j8 This specifies the number of parallel operations. Use -j8 for a quad core processor and a -j16 for an octa-core.
Once the download completes successfully we will need to download the device specific code, this includes specific applications and kernel configurations for your device. To start downloading the files type:
Code:
source build/envsetup.sh
breakfast angler
The download should now start, it should only take minutes however this depends on your internet connection.
Again once this completes, we need to grab proprietary specific files. We first need to navigate to ~/android/system/device/huawei/angler. You can do this by running the following command:
Code:
cd ~/android/system/device/huawei/angler
As the script we are going to use has some dependencies we will need to get them first.
Code:
git clone https://github.com/JesusFreke/smali
cd smali
./gradlew build
cd ..
Additionally we need to download a Google Stock Image, I'm using angler-mmb29m-factory-8c31db3f.tgz, once downloaded you will need to unzip it and cd to it within the terminal.
and then download:
Code:
wget http://people.canonical.com/~mfisch/tools/ext4_utils.tar.gz
tar xzsf ext4_utils.tar.gz
cd ext4_utils
mv simg2img ../angler-mmb29m/
cd ../angler-mmb29m/
We will now convert the system and vendor img's using simg2img to a readable format and mount them so we extract the propriety files using ./extract_files.sh
We can do all of this by using the following commands.
Code:
./simg2img system.img system.ext4
./simg2img vendor.img vendor.ext4
sudo mkdir -p /mnt/system
sudo mkdir -p /mnt/vendor
sudo mount -rw system.ext4 /mnt/system
sudo mount -rw vendor.ext4 /mnt/vendor
Finally we can extract the proprietary files for the system image by running the following commands.
Code:
cd ~/android/system/device/huawei/angler/
./extract_files /mnt/ smali/
Finally we can finish off by our by running the brunch command to build and generate the .zip file of our own Cyanogenmod.
Code:
brunch angler
Note: This will take 20 mins - 2 hours - 2 days depending on your hardware spec.
And well that's it, the location of your generated .zip file should be in blue at the end of your terminal.
Reserved
N/A
This is amazing. Many thanks.
Great I've been looking
Sent from my XT1526 using XDA Forums Pro.
If there are bugs how can we fix that .Such as camera ,ril.For nexus 6p it is fine but for other phones
AANISH said:
If there are bugs how can we fix that .Such as camera ,ril.For nexus 6p it is fine but for other phones
Click to expand...
Click to collapse
As I have only just started my journey on this long path I have done a bit of research for you. Google released there own device specific binaries for the Nexus devices of which usually include the following:
NFC, Bluetooth and Wi-Fi
Media, Audio, Thermal, Touch Screen, Sensors
GPS, Camera, Gestures, Graphics, DRM, Video
This to me suggests that the chipset suppliers supply them - Broadcom, Qualcomm... or even other companies like Motorola. So if you are looking for binaries for other devices I would start with there chipset.
If you would like to look at Google's binaries following the link below however before you go looking for the 6P binaries they haven't been uploaded yet + if you do find any further information please reply to this comment or PM me.
Just saying, the official guide on the wiki works just fine. Been building for all my CM12-capable devices since 2015. Good for people who don't go there, though.
Sent from Google Nexus 6P @ CM13
[WARNING: XDA One have not implemented "mark forum as read" - do not use]
AndyYan said:
Just saying, the official guide on the wiki works just fine. Been building for all my CM12-capable devices since 2015. Good for people who don't go there, though.
Sent from Google Nexus 6P @ CM13
[WARNING: XDA One have not implemented "mark forum as read" - do not use]
Click to expand...
Click to collapse
That is true but I had major difficulties with it, for example it asks you to initialise the cm 12.1 branch when it wasn't available and I had a major pain with extract_files as it wouldnt use adb but instead had to use stock firmware to grab the proprietary files.
connectionalive said:
That is true but I had major difficulties with it, for example it asks you to initialise the cm 12.1 branch when it wasn't available and I had a major pain with extract_files as it wouldnt use adb but instead had to use stock firmware to grab the proprietary files.
Click to expand...
Click to collapse
You still have to spot the tiny mistakes in the guide, of course. The guide hasn't been updated in a long time.
I didn't grab any proprietary files for any of my devices and the builds still run fine - the files should already be in the repo.
Sent from Google Nexus 6P @ CM13
[WARNING: XDA One have not implemented "mark forum as read" - do not use]
AndyYan said:
You still have to spot the tiny mistakes in the guide, of course. The guide hasn't been updated in a long time.
I didn't grab any proprietary files for any of my devices and the builds still run fine - the files should already be in the repo.
Sent from Google Nexus 6P @ CM13
[WARNING: XDA One have not implemented "mark forum as read" - do not use]
Click to expand...
Click to collapse
Ah I didn't know this, I have only just started learning and researching all of this so all helps, if you could point me in the right direction, it would be greatly appreciated.
connectionalive said:
Ah I didn't know this, I have only just started learning and researching all of this so all helps, if you could point me in the right direction, it would be greatly appreciated.
Click to expand...
Click to collapse
I'm also just at the beginning - building according to official guides without modifying the source. Just giving some tips so that you don't step on the same mines as I did
P.S. Transition from CM12.1 to CM13 was a real PITA...
Sent from Google Nexus 6P @ CM13
[WARNING: XDA One have not implemented "mark forum as read" - do not use]
Great guide, I have a build environment setup on Linux Mint, but I am curious to know if the simg2img stuff and extraction is necessary, I thought the initial build process took care of that??
adzcache said:
Great guide, I have a build environment setup on Linux Mint, but I am curious to know if the simg2img stuff and extraction is necessary, I thought the initial build process took care of that??
Click to expand...
Click to collapse
It's not, it's a lot easier to just use the Muppets and not worry about it.
akellar said:
It's not, it's a lot easier to just use the Muppets and not worry about it.
Click to expand...
Click to collapse
I suppose I should start learning how to building up a roomservice.xml for this 6P then. Thanks for the confirmation.
akellar said:
It's not, it's a lot easier to just use the Muppets and not worry about it.
Click to expand...
Click to collapse
I couldn't find it on their repository under Google or Huawei
connectionalive said:
I couldn't find it on their repository under Google or Huawei
Click to expand...
Click to collapse
Look under the right branch
Code:
./simg2img system.img system.ext4
./simg2img vendor.img vendor.ext4
sudo mkdir -p /mnt/system
sudo mkdir -p /mnt/vendor
sudo mount -rw system.ext4 /mnt/system
sudo mount -rw vendor.ext4 /mnt/vendor
Code:
cd ~/android/system/device/huawei/angler/
./extract_files /mnt/ smali/
You have to take ownership of the mounted images before you can extract the blobs. Otherwise you have to use sudo for extract. Then the folder is root and make is denied permission while compiling.
XxMORPHEOUSxX said:
Code:
./simg2img system.img system.ext4
./simg2img vendor.img vendor.ext4
sudo mkdir -p /mnt/system
sudo mkdir -p /mnt/vendor
sudo mount -rw system.ext4 /mnt/system
sudo mount -rw vendor.ext4 /mnt/vendor
Code:
cd ~/android/system/device/huawei/angler/
./extract_files /mnt/ smali/
You have to take ownership of the mounted images before you can extract the blobs. Otherwise you have to use sudo for extract. Then the folder is root and make is denied permission while compiling.
Click to expand...
Click to collapse
I had no issues when actioning any of these commands but in theory you are correct.
connectionalive said:
I had no issues when actioning any of these commands but in theory you are correct.
Click to expand...
Click to collapse
I ran into issues. That's why I mentioned it. Also the extract-files tool is formatted different in my tree. After mounting these were are my exact commands. Maybe it will help someone else.
Code:
sudo chown -hR <user> /mnt/system
sudo chown -hR <user> /mnt/vendor
cd ~/android/system/device/huawei/angler
./extract-files.sh /mnt/ smali/
Hola
I have gone through this guide (really well put together) but I am getting an error almost at the very end and I need some guidance please:
I invoke brunch angler command but it shows:
~/android/system/device/huawei/angler$ brunch angler
bash: build/tools/roomservice.py: No such file or directory
** Don't have a product spec for: 'cm_angler'
** Do you have the right repo manifest?
No such item in brunch menu. Try 'breakfast'
I tried the lunch and breakfast commands but it comes up with the same error.
I did run both:
source build/envsetup.sh
breakfast angler
from the right directory and no errors came up. Can anyone assist me? Thanks.

[DEV] Ubuntu 18.04 LTS Bionic (Linux for Tegra) for SHIELD Android TV

This is a full featured port of NVIDIA L4T R32.7.2 (Ubuntu 18.04) for the SHIELD TV (2015, 2017). It has full hardware support including:
GPU acceleration
Wifi/Bluetooh
USB 3.0
HDMI with audio
microSD (supported models)
Power management
etc
Download​Download Latest (R32.7.2, 07/09/22)
Details​The main challenge in this port was getting the right kernel version to match with the on-device DTB. The DTB is structured in a way that Cboot must be able to parse (and modify it) and then Linux kernel must be able to parse it as well. There are various issue with previous documented methods of flashing a Jetson DTB. NVIDIA stopped distributing SHIELD TV (Foster) DTBs with L4T releases years ago so you would have to manually port a newer DTB or be stuck with an older kernel. Flashing an (years) older DTB is not an option because a newer Cboot will fail to parse it and you'll end up with a brick. Flashing a custom DTB is dangerous for this reason as well. Flashing an older Cboot is not possible due to signature requirements even on an unlocked device. So we are stuck with one option: build a L4T kernel around the device's Android DTB.
NVIDIA maintains two forks of Linux for Tegra X1. The L4T kernel and the Android (downstream) kernel are not 1-to-1 compatible. DTB property names can differ, ioctl structure sizes can differ, etc. I tried various ways to cleanly merge the two and ended up with the following working strategy:
Kernel 4.9 + NVIDIA drivers from Android fork
Build config from L4T release hand merged with options from the Android TV kernel
NVGPU drivers from L4T fork (due to lack of source for and need for compatibility with userland drivers)
Initramfs from L4T release
I also had to port some patches from one fork to the other (especially for NVGPU). The end result is a kernel that combines both forks and therefore is relatively stable and fully featured.
Booting​
The build is tested with the 9.0.0 and 9.1.0 release. It is recommended that you update to 9.0.0.
Note that once you update Cboot, you cannot downgrade to a lower version anymore! If you do not update, some things may not work properly due to the DTB differences noted above however, any relatively "modern" build may still work.
You need a USB drive with at least 8GB of free space. Flash rootfs.img to the first partition (replace sdX1 with your USB drive partition):
Code:
$ sudo dd if=rootfs.img of=/dev/sdX1 bs=1MiB
Make sure your SHIELD TV is unlocked and connected to fastboot.
Either boot the kernel directly:
Code:
$ fastboot boot boot.img
Or you may also flash the kernel if you want to:
Code:
$ fastboot flash boot boot.img
$ fastboot reboot
The initramfs will attempt to boot from the following devices (in order):
1. sda1: First partition of external USB on 16GB model
2. sdb1: First partition of external USB on 500GB model
3. mmcblk2p1: First partition of microSD on supported models
4. mmcblk0p29: Userdata partition of eMMC on 16GB model
5. sda32: Userdata partition of HDD on 500GB model
6. sda33: Partition 33 of HDD on 500GB model (partition table modification needed)
7. sda34: Partition 34 of HDD on 500GB model (partition table modification needed)
8. mmcblk0p19: System partition of eMMC on 16GB model (too small to hold rootfs unless partition table is modified)
After installation, you should resize the partition if your device is > 8GB (replace sdX1 with your installation device).
Code:
$ sudo e2fsck -f /dev/sdX1
$ sudo resize2fs /dev/sdX1
Flashing to internal eMMC​
If you wish to flash rootfs to your internal eMMC, you need to first install to a USB and boot into Ubuntu. Flashing from fastboot will NOT work due to some eMMC issues (I think Cboot does not respect the block remap).
The following will flash to the userdata partition and will WIPE any existing data on the device!
Code:
$ sudo dd if=rootfs.img of=/dev/mmcblk0p29 bs=1MiB
$ sudo e2fsck -f /dev/mmcblk0p29
$ sudo resize2fs /dev/mmcblk0p29
You can follow similar steps to flash to sda32 on a 500GB model. Follow the steps in the first section to flash boot.img.
Uninstalling​
As long as you didn't touch the other partitions, you can easily restore Android TV with the recovery images.
Code:
$ fastboot erase userdata
$ fastboot flash boot nv-recovery-image-shield-atv-9.0.0/boot.img
​Troubleshooting​The USB/microSD does not boot and is stuck at a blinking cursor
Make sure you wait long enough (at least five minutes).
Make sure your USB drive (or microSD) is formatted with MBR with a single partition. You should be writing to /dev/sdX1 (X is some letter) with a "1" at the end. Do not write to /dev/sdX.
Try to mark the first partition as bootable.
Manual Build​Download Latest (R32.7.2, 07/09/22)
Prerequisite​
Linux for Tegra R32.7.2
Linux for Tegra R32.7.2 Sources
Linux for Tegra R32.7.2 Root Filesystem
Jetson GCC Toolchain 32.2
NVIDIA SHIELD ANDROID TV 2015 Recovery OS Image 9.0.0
Utilities (apt install): simg2img, git, fastboot, abootimg
Building the kernel​
1. Install the toolchain.
Code:
$ wget -O toolchain.tar.xz https://developer.nvidia.com/embedded/dlc/l4t-gcc-7-3-1-toolchain-64-bit
$ tar xpf toolchain.tar.xz
$ sudo mv gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu /opt/l4t-toolchain
2. Fetch the SHIELD TV Android kernel sources.
Code:
$ git clone --depth 1 https://nv-tegra.nvidia.com/r/linux-4.9.git -b rel-shield-r-9.0.2-opensource-4.9 linux-4.9
$ git clone --depth 1 https://nv-tegra.nvidia.com/r/linux-nvidia.git -b rel-shield-r-9.0.2-opensource nvidia
3. Fetch the Linux For Tegra NVGPU sources.
Code:
$ wget https://developer.nvidia.com/embedded/l4t/r32_release_v7.2/sources/t210/public_sources.tbz2
$ tar xpf public_sources.tbz2
$ tar xpf Linux_for_Tegra/source/public/kernel_src.tbz2
$ mv kernel/nvgpu nvgpu
You should have three directories: linux-4.9, nvidia, and nvgpu
4. Patch the sources.
Code:
$ cat patches/kernel-4.9/*.patch | patch -p1 -dlinux-4.9
$ cat patches/nvidia/*.patch | patch -p1 -dnvidia
$ cat patches/nvgpu/*.patch | patch -p1 -dnvgpu
5. Build the kernel and install the modules.
Code:
$ export CROSS_COMPILE=/opt/l4t-toolchain/bin/aarch64-linux-gnu-
$ export ARCH=arm64
$ mkdir -p Linux_for_Tegra/rootfs/
$ pushd linux-4.9
$ make shieldtv_defconfig
$ make -j$(nproc) zImage
$ make -j$(nproc) modules
$ make modules_install INSTALL_MOD_PATH=../Linux_for_Tegra/rootfs/
$ sudo chown -R root:root ../Linux_for_Tegra/rootfs/lib
$ popd
Building Root Filesystem​
1. Extract jetson-210_linux_r32.7.2_aarch64.tbz2 and tegra_linux_sample-root-filesystem_r32.7.2_aarch64.tbz2.
Code:
$ tar xpf jetson-210_linux_r32.7.2_aarch64.tbz2
$ pushd Linux_for_Tegra/rootfs/
$ sudo tar xpf ../../tegra_linux_sample-root-filesystem_r32.7.2_aarch64.tbz2
$ sudo touch etc/nv_boot_control.conf
Note the use of sudo for the last two commands. This is required for file permissions to be correct. The touch at the end resolves a bug in NVIDIA's code that resulted in the installer not launching.
2. Install the filesystem.
Code:
$ cd ..
$ sudo ./apply_binaries.sh
$ popd
3. To enable Wifi and NVDEC, need to first convert vendor.img downlaoded from the SHIELD recovery image to an ext4 image.
Code:
$ simg2img nv-recovery-image-shield-atv-9.0.0/vendor.img vendor-raw.img
4. Next mount the image.
Code:
$ mkdir vendor
$ sudo mount -o loop vendor-raw.img vendor
5. Copy the firmware over.
Code:
$ sudo cp vendor/firmware/bcmdhd_clm_foster.blob Linux_for_Tegra/rootfs/lib/firmware/brcm/bcmdhd.clm_blob
$ sudo cp vendor/firmware/fw_bcmdhd.bin Linux_for_Tegra/rootfs/lib/firmware/brcm/fw_bcmdhd.bin
$ sudo cp vendor/firmware/nvram_foster_e_4354.txt Linux_for_Tegra/rootfs/lib/firmware/brcm/nvram.txt
$ sudo cp vendor/firmware/tegra21x/* Linux_for_Tegra/rootfs/lib/firmware/tegra21x/
$ sudo cp vendor/firmware/tegra21x/vic04_ucode.bin Linux_for_Tegra/rootfs/lib/firmware/nvidia/tegra210/
$ sudo umount vendor
6. Create and mount a new ext4 image. Note that we will create 8GiB image which should be enough to hold the root filesystem. After you flash it to your device and boot successfully, you'll want to run resize2fs.
Code:
$ dd if=/dev/zero of=rootfs.img bs=1MiB count=8196
$ mkfs.ext4 rootfs.img
$ mkdir mount
$ sudo mount -o loop rootfs.img mount
7. Copy the filesystem to the disk image.
Code:
$ sudo mv Linux_for_Tegra/rootfs/* mount/
$ sudo umount mount
Building boot image​
1. Extract the existing initramfs.
Code:
$ mkdir initramfs
$ pushd initramfs
$ cat Linux_for_Tegra/bootloader/l4t_initrd.img | gunzip -c | cpio -i
2. Patch init.
Code:
$ cp patches/initramfs/init init
3. Rebuild the image.
Code:
$ find ./ | cpio -H newc -o -R root:root | gzip -9 -c > ../initramfs.img
4. Build boot.img
Code:
$ abootimg --create boot.img -f patches/bootimg.cfg -k linux-4.9/arch/arm64/boot/zImage -r initramfs.img
I've updated the download to fix an issue I found with connecting to 5GHz wifi. Using the other nvram.txt fixed it. I also noticed that NVENC/NVDEC doesn't work properly and am unsure if it's a kernel issue or a L4T issue. I tried building with nvdec bootloader disabled and used L4T's ns firmware and it still didn't work.
EDIT: Made another update to fix the NVENC/NVDEC issue. Additionally, the led lightbar control driver is added in. I also made the following systemd script to disable the lightbar at boot.
Code:
[Unit]
Description=Disable the lightbar
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=-/bin/sh -c "/sbin/rmmod leds-cy8c && /sbin/modprobe leds-cy8c"
ExecStart=/bin/sh -c "echo 0 > /sys/class/leds/led_lightbar/brightness"
ExecStop=/bin/sh -c "echo 255 > /sys/class/leds/led_lightbar/brightness"
[Install]
WantedBy=multi-user.target
Is this a fully working ubuntu desktop OS experience or is this a Kernel for the shield?
EgomafiaX said:
Is this a fully working ubuntu desktop OS experience or is this a Kernel for the shield?
Click to expand...
Click to collapse
Full Ubuntu 18.04, it’s not just a kernel. I’ve been using it for the past week and haven’t run into any issues so far. You can try it out without modifying anything by flashing rootfs.img to a usb drive and booting the kernel from fastboot.
Very Interesting, I just got my shield last week and i wanna try some few things on it. Don’t have any experience with flashing whatsoever
What's performance like? I was thinking of buying a new SBC but this could be just what I am looking for
moshtin said:
What's performance like? I was thinking of buying a new SBC but this could be just what I am looking for
Click to expand...
Click to collapse
Nvidia SHIELD TV Benchmarks in Ubuntu Shows Core i3 Like Performance - CNX Software
Nvidia SHIELD Android TV was announced this March with Nvidia Tegra X1 octa-core Cortex A57 + A53 processor. So far, I had not seen any Ubuntu or other
www.cnx-software.com
Hi!
Thanks for your work.
This seems promising. Any chance anything similar should work on SHIELD TV Pro (2019)?
I compared recovery images provided by NVIDIA and I did not come across many differences between vendor binaries so I guess there is won't be any issue with the roottfs and kernel.
However on the SHIELD TV Pro, the boot.img is twice as big and the recovery image seems to contain a DTB image (mdarcy.dtb.img) and a vbmeta.img. I suspect the boot process to be somewhat different on this plateform.
Did anyone manage to get anything working on a SHIELD TV Pro?
yifanlu said:
$ pushd kernel-4.9
Click to expand...
Click to collapse
I guess you meant:
Code:
$ pushd linux-4.9
yifanlu said:
$ sudo mv Linux_for_Tegra/rootfs/rootfs/* mount/
Click to expand...
Click to collapse
and
Code:
$ sudo mv Linux_for_Tegra/rootfs/* mount/
Also the shieldtv_defconfig is located in arm/ instead of arm64/ in the patches you provide.
I tried the instructions from the first post on a Shield TV (2017) model and after doing "fastboot boot boot.img" the screen goes black with a blinking underscore on the top left and gets stuck there.
Any idea on what could be wrong? I dd'ed the rootfs.img to a usb stick attached to the usb port adjacent to the hdmi port. The usb A->A cable for fastboot/adb is attached to the usb port away from the hdmi cable.
chaitan3 said:
I tried the instructions from the first post on a Shield TV (2017) model and after doing "fastboot boot boot.img" the screen goes black with a blinking underscore on the top left and gets stuck there.
Any idea on what could be wrong? I dd'ed the rootfs.img to a usb stick attached to the usb port adjacent to the hdmi port. The usb A->A cable for fastboot/adb is attached to the usb port away from the hdmi cable.
Click to expand...
Click to collapse
I also seem to have hit same roadblock, did you succed with this.
kihmathi said:
I also seem to have hit same roadblock, did you succed with this.
Click to expand...
Click to collapse
No, I have not been able to proceed. @yifanlu any hints on what we could do to debug?
I only have a 2015 shieldtv but I read the hardware are the same. Maybe I was wrong and there’s some kernel changes needed. I would diff the defconfig between the latest android release for both and see what the differences are. Then add those to the config.
EDIT: I downloaded the recovery image for 2017 and compared the kernel defconfig and it’s identical. That means the kernel isn’t the issue. My next guess would be the init script I wrote. Maybe the dev number is different on 2017?
Can confirm, I have the same issue on model P2897 not pro.
In my init script, I wait 10s for the root device to show up before giving up and trying the next one. Perhaps this isn’t long enough?
If you update the init file inside the initramfs, there is on line 71 “while [ ${count} -lt 20 ]” maybe change that to “while [ ${count} -lt 100 ]” to try 100 times (with 0.2s in between).
Could anyone here running this image try out https://github.com/cobalt2727/L4T-Megascript? It's been tested against the base model Nintendo Switch and a Jetson Nano, but no Shield hardware so far (although it should perfectly support it in theory)
yifanlu said:
In my init script, I wait 10s for the root device to show up before giving up and trying the next one. Perhaps this isn’t long enough?
If you update the init file inside the initramfs, there is on line 71 “while [ ${count} -lt 20 ]” maybe change that to “while [ ${count} -lt 100 ]” to try 100 times (with 0.2s in between).
Click to expand...
Click to collapse
I tried this on my 2017 shield, didn't fix the issue, there is a blinking underscore on the top left. Is there any way to get logs, or show some debug messages on the screen?

Categories

Resources