Auto-USB updater script - Raspberry Pi General

I thought you guys might find this useful. While I was making my auto root box, I found myself needing to update the software frequently. I came up with a script which pulls the new files over automatically. Tthat's not ideal when working with a headless device.
So, I made a script that mounts the USB thumb drive, if it's plugged in, and copies new versions of my binaries to the device. This allows me to develop on a desktop and test by simply copying to a thumb drive, plugging it into the Raspi, and turning the Raspi on. After using this, the device boots up normally and to make changes to the filesystem you simply plug in a USB drive with changes. They will be replicated to the Raspberry Pi's filesystem on reboot.
Edit your /etc/rc.local file and add the following:
Code:
mkdir /media/update
mount /dev/sda /media/update
cp /media/update/NameOfFile.ext /PATH_TO_DESTINATION/
cp /media/update/NameOfFile.ext /PATH_TO_DESTINATION/
cp /media/update/NameOfFile.ext /PATH_TO_DESTINATION/
umount /media/update
If you'd like to make it completely generic as in you don't know what you will be changing...
Code:
mkdir /media/update
mount /dev/sda /media/update
cp /media/update/ /
umount /media/update
The second method can be risky because you have the potential to destroy the entire filesystem.
Hope this helps with someone's embedded project.

Hi Adam, got my gs3 there you are, got my galaxy camera there you are now got rasberry pi here you are. Think ill buy a Ferrari next lol
Sent from another galaxy using Tapatalk 2

Related

[HOWTO] for Gamers: dirty workaround to have Gameloft files on external_sd

No need for scripts. Search for GL to SD app, much easier.
------
I'm not a heavy gamer, but usually have tons of games installed on my phone for my kid to play with (trying to resist to the "daddy, I wanna a PSP" while I can, at least with the phone I can control when he plays ).
With the advent of HD games, it become more and more difficult to manage multiple game installations on sdcard. The last drop was Asphalt6, with its +500M of downloaded files.... soon will have to use external hard disks to use games on our phones . Most of the "heavy" games are from Gameloft, and the problem lies on the installation pack that doesn't ask for a location to install additional files, always assuming sdcard.
Looked around, and the only workaround I've found was a crack that opens the game apk and changes the download destination directory. Well, I wasn't very comfortable in using this, and it only worked on some games.
So I configured the following "dirty" workaround, I know it's not perfect, but it resolved my problem so I decided to share here.
Basically I've moved gameloft directory from sdcard to external_sd and created a bind mount point called gameloft on sdcard pointing to external_sd. This has the problem that you can only mount that bind point before using the gameloft games, because if you keep it mounted and use storage usb you'll have problems mounting sdcard.
So I've created two scripts - one to mount it, another to unmount it -, and using script manager created a shortcut (actually is a script manager widget) to both scripts on my screen. Whenever I want to use/install gameloft games I mount it, and in the end dismount the bind.
Additional steps for gamming, but restored my sdcard space and now I can use my 16G external sd for that files. Note that if your external card is slow, the game load will be slower.
EDIT: This procedure needs root and busybox. Sorry forgot to mention earlier, I never had my phone not rooted
So, the how-to for anyone who wants to try:
1 - copy /sdcard/gameloft to /sdcard/external_sd/gameloft (if you don't have any GL games installed just create the folder /sdcard/external_sd/gameloft)
2 - remove /sdcard/gameloft/ contents
3 - create the following scripts on sdcard:
mount_gl.sh
Code:
#!/system/bin/sh
# mounts bind point
if [ -e /sdcard/gameloft ];
then
if [ -e /sdcard/external_sd/gameloft ];
then
busybox mount -o bind /sdcard/external_sd/gameloft/ /sdcard/gameloft
else
echo "no gameloft dir on external_sd"
fi;
else
echo "no gameloft dir on sdcard"
fi;
umount_gl.sh
Code:
#!/system/bin/sh
# UNmounts bind point
if [ -e /sdcard/gameloft ];
then
busybox umount -l /sdcard/gameloft
else
echo "no gameloft dir on sdcard"
fi;
Run first to mount, and check /sdcard/gameloft/ contents. If everything ok, start game and try.
Remember that to simplify you can create shortcuts of the scripts using script manager.
Try not to leave the bind mounted. If by any chance you forget to unmount the bind and use usb storage, you wont be able to mount sdcard, but there's no need to stress . Just unmount usb storage, open adb shell (or a terminal on phone) and issue the command:
# umount /sdcard/gameloft
after that mount usb storage, unmount it again, and everything will be back to normal.
If you at some point regret the change, just move the content of /sdcard/external_sd/gameloft to /sdcard/gameloft/.
The usual disclaimer: I provide this to share my findings, use it at your own risk. AFAIK there's no risk on this operation, besides the fact you could have to download files again if something goes wrong, but I didn't test this on any other phones besides mine.
EDIT 08/19: updated scripts with feedback from thread - added busybox to mount/umount and added -l switch to umount.
Cheers
nice idea.
Can I do this method with symbolic link too?
No. Symlinks are not supported by fat filesystem, the only way I've found was trough bind mount point.
Sent from my GT-I9000 using XDA App
I tried this method and didn't worked for me =(.
When i execute the script in script manager show me this error:
exec sh '/mnt/sdcard/mount_gl.sh'
$ exec sh '/mnt/sdcard/mount_gl.sh'
: not found
/mnt/sdcard/mount_gl.sh: 11: Syntax error: "fi"
unexpected (expecting "then")
tanke234 said:
I tried this method and didn't worked for me =(.
When i execute the script in script manager show me this error:
exec sh '/mnt/sdcard/mount_gl.sh'
$ exec sh '/mnt/sdcard/mount_gl.sh'
: not found
/mnt/sdcard/mount_gl.sh: 11: Syntax error: "fi"
unexpected (expecting "then")
Click to expand...
Click to collapse
It looks like you don't have busybox installed. Do you have it?
My bad, didn't mention it on OP, sorry.
Try to open a terminal emulator on phone and execute:
$ sh /mnt/sdcard/mount_gl.sh
just to make sure its not script manager related.
Sent from my GT-I9000 using XDA App
u can use busybox umount -l /sdcard/gameloft in case umount doesn't work. when sdcard being used by some background program, normal umount not working. Tested with O2X though
I use JVR with latest semaphore kernel and i guess that this kernel has busybox v1.16.2. Am i wrong?
lunasea said:
Try to open a terminal emulator on phone and execute:
$ sh /mnt/sdcard/mount_gl.sh
just to make sure its not script manager related.
Click to expand...
Click to collapse
I tried that on terminal emulator and i get the same error ;S
tanke234 said:
I use JVR with latest semaphore kernel and i guess that this kernel has busybox v1.16.2. Am i wrong?
I tried that on terminal emulator and i get the same error ;S
Click to expand...
Click to collapse
The code is wrong in the mount script, there's duplication
it should be:
Code:
#!/system/bin/sh
# mounts bind point
if [ -e /sdcard/gameloft ];
then
mount -o bind /sdcard/external_sd/gameloft/ /sdcard/gameloft
else
echo "no gameloft dir on external_sd"
fi;
and make sure you leave the /sdcard/gameloft folder where it is (even though it'll be empty)
shinigamis said:
u can use busybox umount -l /sdcard/gameloft in case umount doesn't work. when sdcard being used by some background program, normal umount not working. Tested with O2X though
Click to expand...
Click to collapse
can confirm this works, OP's unmount brings up 'files in use' or similar error sometimes..
on a side note, didn't know android was so picky when it comes to case.. if "Busybox" is used then you get a busybox: not found error, has to be lowercase
anyway, for the sake of clarity for other users:
Code:
busybox umount -l /sdcard/gameloft
viva.fidel said:
The code is wrong in the mount script, there's duplication
it should be:
Code:
#!/system/bin/sh
# mounts bind point
if [ -e /sdcard/gameloft ];
then
mount -o bind /sdcard/external_sd/gameloft/ /sdcard/gameloft
else
echo "no gameloft dir on external_sd"
fi;
and make sure you leave the /sdcard/gameloft folder where it is (even though it'll be empty)
Click to expand...
Click to collapse
I'm testing different locations, so no duplication. But be free to optimize the scripts, my programing is quite rusty this days.
Android is linux based, thus sensitive to capitalised words. About mount needing busybox, already happened to me on some rom/kernel combination. Using surface + talon and don't need to add busybox before the commands thought.
Sorry about the problems, like I said only tested on my sgs.
Cheers
Sent from my GT-I9000 using XDA App
Already tested this "script method" and working flawlessly.
Just a note: Hero of Sparta bounced to homescreen when loading main menu (after the opening video). But I can assure you this is not the fault of the script because HoS also not working when using patching method.
XA-R01 said:
Already tested this "script method" and working flawlessly.
Just a note: Hero of Sparta bounced to homescreen when loading main menu (after the opening video). But I can assure you this is not the fault of the script because HoS also not working when using patching method.
Click to expand...
Click to collapse
Dont have HoS, so thanks for the feedback. Maybe gameloft is making some control over the installed files because of illegal copy. Wish they put the same effort on resolving the installation issue, dont know why its so hard to ask the location instead of assuming a location for the download files.
Sent from my GT-I9000 using XDA App
I thought symlinks could do the trick as well (you wouldn't need scripts), but using mount points is a smart way as well! Thanks for sharing!
Will this work on SG2?
justmiike said:
Will this work on SG2?
Click to expand...
Click to collapse
Don't know mate, the scripts are pretty generic thought, as long there's a sdcard and an external_sd dir.
Taptalked... holding it the right way.
good guide!will try it later...coz im a heavy gamer ..cant resist any RPG game..and it really eat so much space in my int SD, here a "thanks" for u
sgsmaniac said:
good guide!will try it later...coz im a heavy gamer ..cant resist any RPG game..and it really eat so much space in my int SD, here a "thanks" for u
Click to expand...
Click to collapse
Thanks... happy gaming
Taptalked... holding it the right way.
justmiike said:
Will this work on SG2?
Click to expand...
Click to collapse
Yes..
The script is generic, you can make it work on another Android Phone with internal SD such as LG, Atrix, etc.
I'm using this patch (Auto_Patch_APK_for_Samsung_by_Duero__include_Java_.exe) in order to place the game data into external memory. Most of Gameloft games work using this method except games which download from market. Just patch the apk file and after install them your game data will stored in folder Gl at your external memory.
So far only this games which not able to patch into external SD
-assassin creed
-hero of sparta
-hawk
Is it possible to mount and unmount usb storage via script?
What I'd like to achieve is the following:
usb storage mount script:
1. unbind directories
2. mount as usb storage
usb storage unmount script:
1. unmount usb storage
2. 10 sec pause
3. bind directories
This way, instead of running the script when playing games (or in my case, using music streaming app such as MOG and Grooveshark), I can run the scripts when I want to mount/unmount as usb storage. After all, I'd be using music apps more than I would use usb storage.

Linux chroot mount scripts

The actual creation of an arm linux chroot image is probably out here on teh internetz somewhere, but I can assist with my mounting shell script (which works).
My image is of a debian arm chroot, and the image filesystem is ext2 (a good idea for fewer writes. ie innately non-journaling), has been used extensively on fw DE .17 and I'm currently trying it out on WW .29 (thank you, miloj).
I would upload my debian img somewhere, but I've actually broken it somewhat (it works for my needs, but it's nonetheless a bit too hacked up to be reliable).
I've modified it somewhat for generalization, some of it is probably wrong and/or redundant, and it IS hackish and ugly, but it works for me (tm).
* the chroot image only need a root account (and probably bash installed, but it usually is)
* You need busybox installed.
* You need to upload your chroot image named linux.img to the internal sdcard in a folder named linux
A shell script to set things up is attached.
What you need to do:
push the install script and run it:
Code:
adb push installlinuxstuff.sh /data/local/
adb shell sh /data/local/installlinuxstuff.sh
Now you can (from adb shell or terminal emulator on device):
Code:
su -
/data/local/mnt/linux.sh
/data/local/mnt/notlinux.sh
Feel free to remove the install script at
/data/local/installlinuxstuff.sh
when you've got it up and running.
Alternative way to run the scripts from adb shell:
Code:
adb shell su -c /data/local/mnt/linux.sh
adb shell su -c /data/local/mnt/notlinux.sh
I usually symlink start and stop (in my case deb and undeb) shell scripts placed in /data/local/mnt in /system/bin (ie shell scripts with 'su -c /data/local/mnt/whatever.sh' in them) for easy start an stop from terminal emulator, and if you've gotten this far you may welcome the small advice. (in other words - don't do this unless you _really_ know what you're doing)
Debian ARMHF or ARMEL?
If you would uploaded it (good place is google drive , sharing as public, as there are no ads or bull**** and the download is extremely fast) I would love to try your image - after modifying your script so it can work on a UHS-1 class MicroSD I want to try running this off of (should give it a little more speed).
zamaditix said:
Debian ARMHF or ARMEL?
If you would uploaded it (good place is google drive , sharing as public, as there are no ads or bull**** and the download is extremely fast) I would love to try your image - after modifying your script so it can work on a UHS-1 class MicroSD I want to try running this off of (should give it a little more speed).
Click to expand...
Click to collapse
Armel (I use the same chroot installation on my phone in a smaller image file (with less stuff installed)). I've got loads of personal stuff all over it and besides - it's somewhat broken. I really don't want to try to fix it.
So I'm working on retracing my steps, creating a clean armhf ext2 image (debian wheezy base installation for now) and redo the mount script, but I can't make any promises on a release date.
Anyhu - there are loads of images (armel, at least) on teh internetz (BT5 and too many ubuntu, for instance).
Just check so our kernel can mount the filesystem.
Edit: if not you can just create a new image file with a filsystem that's mountable and copy the chroot files to it.
So the ideal image for this tablet is armhf? If I wanted to create a Gentoo image, I would go with armv7? I'm just not sure exactly which ARM architecture this tablet is.
EndlessDissent said:
So the ideal image for this tablet is armhf? If I wanted to create a Gentoo image, I would go with armv7? I'm just not sure exactly which ARM architecture this tablet is.
Click to expand...
Click to collapse
The CPU is the Tegra 3 if you want to google it and it is an ARMv7 w/ NEON extensions chip. ARMv7 specification requires hardware fp so naturally it is ARMhf.
Nice to hear, keep us updated on your progress. I'm currently running an armel copy of Ubuntu 12.04 but it has problems with some packages and others are armhf only.
When I run linux.sh, I get an error that /sdcard can't be mounted because it doesn't exist.
Code:
mount: mounting /sdcard on /data/local/mnt/linux/sdcard failed: No such file or directory
I also tried changing the script to mount /mnt/sdcard, but that didn't work either.
EndlessDissent said:
When I run linux.sh, I get an error that /sdcard can't be mounted because it doesn't exist.
Code:
mount: mounting /sdcard on /data/local/mnt/linux/sdcard failed: No such file or directory
I also tried changing the script to mount /mnt/sdcard, but that didn't work either.
Click to expand...
Click to collapse
Yes, it is somewhat hackish, like I wrote. My image has got an sdcard folder (/sdcard) inside of it where I mount /sdcard from android. (Ie chroot and mkdir /sdcard)
followed this:
http://androlinux.com/android-ubuntu-development/how-to-install-ubuntu-on-rooted-transformer-prime/
make sure you have busybox installed der. Or at least the cp command in /system/bin
works well on my TF300T, Yea its not native but im currently configuring it for kernel building ;-D
FlyingPoo said:
followed this:
http://androlinux.com/android-ubuntu-development/how-to-install-ubuntu-on-rooted-transformer-prime/
make sure you have busybox installed der. Or at least the cp command in /system/bin
works well on my TF300T, Yea its not native but im currently configuring it for kernel building ;-D
Click to expand...
Click to collapse
Why does the mount script remount a non-existing block device with an ancient (according to android) filesystem?
Code:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Edit: I read all the scripts, and they all mount that crap. It's not made for transformers, and on the android device it's made for it leaves /system mounted rw after you've run it, and WHEN run (installed) it modifies too much in /system/bin
Code:
# At first it copies loads of crap to /system/bin, and then:
cd /system/bin/
chmod 4777 *
It's not even "hackish" - it's just... wrong...
Will loop1 work every mount?
Code:
mknod /dev/loop1 b 7 0
losetup /dev/block/loop1
I'm almost only asking, since this thread was supposed to be about scripts?
gasingvar said:
Yes, it is somewhat hackish, like I wrote. My image has got an sdcard folder (/sdcard) inside of it where I mount /sdcard from android. (Ie chroot and mkdir /sdcard)
Click to expand...
Click to collapse
Thanks. I created /sdcard, and it works almost perfectly now. However, mounting devpts at /dev/pts doesn't seem to work. I replaced that line with
Code:
mount --bind /dev $mnt/dev
and it seems to work fine. Is there anything wrong with my method?
/dev/void said:
Why does the mount script remount a non-existing block device with an ancient (according to android) filesystem?
Code:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Edit: I read all the scripts, and they all mount that crap. It's not made for transformers, and on the android device it's made for it leaves /system mounted rw after you've run it, and WHEN run (installed) it modifies too much in /system/bin
Code:
# At first it copies loads of crap to /system/bin, and then:
cd /system/bin/
chmod 4777 *
It's not even "hackish" - it's just... wrong...
Will loop1 work every mount?
Code:
mknod /dev/loop1 b 7 0
losetup /dev/block/loop1
I'm almost only asking, since this thread was supposed to be about scripts?
Click to expand...
Click to collapse
I'm assuming you're talking about the link in the post you quoted, even though you seem to be referencing the OP's use of the word "hackish". The script in the OP doesn't do any of that stuff. It just creates a few directories in /data/local/mnt/ and writes the mount/unmount scripts, which themselves only un/mount appropriate directories for the tablet. As for your question, I'm not nearly experienced enough to answer it. Sorry.
EndlessDissent said:
Thanks. I created /sdcard, and it works almost perfectly now. However, mounting devpts at /dev/pts doesn't seem to work. I replaced that line with
Code:
mount --bind /dev $mnt/dev
and it seems to work fine. Is there anything wrong with my method?
Click to expand...
Click to collapse
AFAIK your mount seems to be more complete, ie more android hardware goodies accessable from the chroot environment. However - that means more things possibly going wrong (like writing to a device who's critical to the android environment).
Personally I'd try to find what "hardware goodies" and whatnot I'd need to get the chroot environment working optimally, and not mount ALL of /dev.
EndlessDissent said:
I'm assuming you're talking about the link in the post you quoted, even though you seem to be referencing the OP's use of the word "hackish". The script in the OP doesn't do any of that stuff. It just creates a few directories in /data/local/mnt/ and writes the mount/unmount scripts, which themselves only un/mount appropriate directories for the tablet. As for your question, I'm not nearly experienced enough to answer it. Sorry.
Click to expand...
Click to collapse
Yes, and the OP is very honest about his script(s) being "hackish", which I interpret to mean 'not optimal, possibly redundant but working', all of which it is (and I applaud the early release, since for instance I could get things rolling), but the ubuntu image installation and mounting scripts from the other poster ( whom I was addressing ) are plain faulty.
I am looking for a armhf build of ubuntu or debian that I can chroot (newer the better), if anyone knows of such a build that would be fantastic but if not does anyone know of an easy to follow guide to compile such a thing?
I found two pretty good guides. I mostly followed THIS ONE, but I found that it doesn't mount enough before "first boot", so what I did was follow the guide until the point where you move the image to the tablet. Then I ran the OP's installlinux.sh script, and then the mount script. However, the mount/unmount scripts need to be edited before using them. Comment out the sdcard line and probably the devpts line (mounting devpts didn't work; Bash complained that devpts didn't exist; I had to replace it with the line I mentioned a few posts above, but as /dev/void says, it could be problematic, so be careful). Mount the image, make the /sdcard directory, exit, unmount, and edit the scripts again to mount/unmount /sdcard.
Next time you enter the chroot, feel free to run the
Code:
sh /debootstrap/debootstrap --second-stage
command to build the image, and follow the linked guide until the next time it tells you to exit the session (NOTE: The second echo "whatever" > sources.list command is wrong; it should be echo "whatever" >> sources.list; Also, remember to replace "squeeze" with the appropriate Debian version, in my case, "testing"). Instead of exiting right after the apt-get update, I'd recommend playing around with the chroot and configuring whatever apps you install. You can just use the OP's scripts now and ignore the script in the linked guide.
When the guide I linked above gets to this line:
Code:
sudo debootstrap --verbose --arch armel --foreign squeeze /mnt/squeeze/ http://ftp.debian.org/debian
just replace armel with armhf, and if you want a testing image, replace squeeze with testing.
Sorry I'm not attaching my image. I made it gigantic (5GB), so I don't really have anywhere to store it, and you probably wouldn't want to download a file that big. Plus, it already has Openbox and a bunch of other things you probably don't want installed. I'm assuming you'd want GNOME or KDE instead.

Getting rid of FAT, UMS, vold

FAT (the old DOS-based file system) is a bad idea.
It's ugly, doesn't mix well with Linux and saves timestamps in local time.
Moreover, the Nook has problems with FAT, randomly changing timestamps a number of hours.
Certainly at daylight savings time transitions everything changes.
If you use timestamps as an indication for syncing files from a host, this is a problem.
UMS (USB Mass Storage) is a bad idea.
It takes a happily mounted volume from an OS, and hands it in a raw block view to a remote system.
Outside of using noogie for full physical backups or initial partitioning and formatting there is no need for UMS.
The last need of UMS was the Adobe Digital Editions which was discussed and obviated in this thread
Finally, there are some devices and occasions where you'd want to hot swap SD cards.
A camera taking megapixels shots might have a need for swapping SD cards.
Our Nooks use SD cards more as permanent expansion units.
Get a 32 GB card, stick it in and never take it out.
Then we wouldn't need vold (the volume daemon).
In another thread I posted a modified vold so that the SD card could be ext3 formatted.
To my mind, the cleanest solution to all this is to:
Format the SD card with ext3
Mount the SD card in init.rc inside the uRamdisk
Disable UMS
Disable vold
Right now I'm running into problems mounting the SD card inside init.rc
Code:
mount ext3 /dev/block/mmcblk1p1 /sdcard wait nosuid nodev noatime nodiratime
chown system sdcard_rw /sdcard
chmod 0777 /sdcard
init has not very useful error reporting, it returns an error of -1 for any condition.
I was trying to build init that could tell me something more.
This is a work in progress.
(If we get rid of vold, we'll have to strip the Android MountWatcher so that it doesn't flail.)
I found out what the problem with doing a normal mount in init.rc was.
The system had not found /dev/block/mmcblk1p1 yet.
I'm still working on this.
For now I have a oneshot service that mounts /sdcard.
It uses a little executable that waits until /dev/block/mmcblk1p1 appears.
I disabled vold.
I would have liked to be able to mount the SD card inside init.rc,
but apparently /dev/block/mmcblk1p1 has not appeared by then.
You need to have a service do the job, a few seconds later.
Yes, you could probably write a little script, but I'd rather write a little Linux program.
I'm still wondering if there is an easier solution to mount inside init.rc
People use their Nooks in such different way.
I would really like to know what exactly people are interested in this thread.
There is a poll at the top to fill in, please.
Pieces of the pie ready to go now:
mke2fs
tune2fs -j
Mods to init.rc - disable vold, enable mntsdcard
mntsdcard - a Linux program
Patches to MountService to disable it.
Is anybody interested in trying this?
Well, if you want to give it a go, here's how.
Black = commands to the Nook shell over ADB
Blue = commands to the Windows shell
Convert your SD card to ext 3
Backup the data on your SD card (or just let it all get deleted).
You can use adbsync.exe if you like:
Code:
[color=blue]mkdir sdcard[/color]
[color=blue]adbsync /hscu /s C:\sdcard sdcard[/color]
Then you can re-partition the SD card.
Code:
umount /sdcard
busybox fdisk -H 255 -S 63 /dev/block/mmcblk1
Do the commands to delete (D) old partitions, create a new (N) primary partition.
Then write (W).
Then format the SD card in ext2, upgrade to ext3 and check the mount.
Code:
mke2fs /dev/block/mmcblk1p1
tune2fs -j /dev/block/mmcblk1p1
mount -t ext3 /dev/block/mmcblk1p1 /sdcard
Install mntsdcard
Copy over mntsdcard:
Code:
mount -o rw,remount /dev/block/mmcblk0p5 /system
[color=blue]adb push mntsdcard /system/bin[/color]
chmod 755 /system/bin/mntsdcard
Get uRamdisk and extract init.rc:
Code:
mount -o rw,remount rootfs /
mkdir /boot
mount -t vfat /dev/block/mmcblk0p1 /boot
[color=blue]adb pull /boot/uRamdisk[/color]
[color=blue]bootutil /x /v uRamdisk init.rc[/color]
Add in a mount for media (we'll leave it FAT for now):
Code:
mount ext2 /dev/block/mmcblk0p5 /system
mount ext2 /dev/block/mmcblk0p5 /system ro remount
[b] mount vfat /dev/block/mmcblk0p6 /media sync noatime nodiratime uid=1000,gid=1000[/b]
Comment the old vold stuff out:
Code:
#service vold /system/bin/vold
# socket vold stream 0660 root mount
Add in the mntsdcard stuff at the end of init.rc:
Code:
service mntsdcard /system/bin/mntsdcard
oneshot
Replace init.rc and push the uRamdisk back:
Code:
[color=blue]bootutil /r /v uRamdisk init.rc
adb push uRamdisk /boot[/color]
reboot
If there are any problems, look in /data/mntsdcard.log
Restore your SD card
Code:
[color=blue]adbsync /ascu /s C:\sdcard sdcard[/color]
Wow, this seems like a lot of stuff to do! :cyclops:
Thanks so much for all this great dev work, Renate!
:good:
BUT!
Will this definitely make noogie not function correctly? (I make new backups with it, like, once every week and a half, so that would definitely stop me from trying this)?
What will this do to the regular USB mounting onto a PC?
What will this do to mounting USB devices on the Nook using host mode?
And, finally: Will this mean I can't ever remove my SD card to use for something else temporarily (or to write a Nook-bootable image to it for miscellaneous reasons)?
Thanks,
3N
It's ugly, doesn't mix well with Linux and saves timestamps in local time.
Click to expand...
Click to collapse
That isn't correct. Linux has had support for FAT file systems very early on
and Linux support is quite stable. Saving timestamps in local time should not be a problem.
These mods look like it would make it non-trivial to side load content (unless you are using Linux for a main PC) for no reason.
smeezekitty said:
...These mods look like it would make it non-trivial to side load content (unless you are using Linux for a main PC) for no reason.
Click to expand...
Click to collapse
Hmmm. Good point. Thanks for pointing this out, as I use a Windows 7.
Here's your first post thank!
smeezekitty said:
TSaving timestamps in local time should not be a problem.
Click to expand...
Click to collapse
It's a problem twice a year when daylight savings time makes all your file times shift one hour.
Also, try moving timezones on your device.
smeezekitty said:
These mods look like it would make it non-trivial to side load content (unless you are using Linux for a main PC) for no reason.
Click to expand...
Click to collapse
Mmm, not really. I have a Windows desktop and I use ADB push/pull and my adbsync utility.
Moreover, I can easily sync all my Android devices before going out the door.
Renate NST said:
...Mmm, not really. I have a Windows desktop and I use ADB push/pull and my adbsync utility.
Moreover, I can easily sync all my Android devices before going out the door.
Click to expand...
Click to collapse
But if we wanted to transfer files without WiFi, ADB wouldn't be available, and so how would we sideload our files w/out ADB?
I agree ADB file transfer is more fun - heck, you can use an FTP Server app and manage your whole filesystem in the comfort of Windows Explorer! But without WiFi...
thenookieforlife3 said:
But if we wanted to transfer files without WiFi, ADB wouldn't be available, and so how would we sideload our files w/out ADB?
I agree ADB file transfer is more fun - heck, you can use an FTP Server app and manage your whole filesystem in the comfort of Windows Explorer! But without WiFi...
Click to expand...
Click to collapse
It is a little harder to set up, but adb usb has been available in the Nook since it was first rooted. This is just one of the multiple threads here that gives instructions....
Getting USB-enabled ADB working
thenookieforlife3 said:
But if we wanted to transfer files without WiFi, ADB wouldn't be available, and so how would we sideload our files w/out ADB?
I agree ADB file transfer is more fun - heck, you can use an FTP Server app and manage your whole filesystem in the comfort of Windows Explorer! But without WiFi...
Click to expand...
Click to collapse
ADB is something a little advanced for me at this point. But regardless of if you want to use it or not,
It is still very handy to be able to just copy files on and off the device just by moving the SD card or mounting by USB
I suggest that the OP adds a note for less experienced users so they know that you lose those capabilities if you do these mods.
smeezekitty said:
ADB is something a little advanced for me at this point. But regardless of if you want to use it or not,
It is still very handy to be able to just copy files on and off the device just by moving the SD card or mounting by USB
I suggest that the OP adds a note for less experienced users so they know that you lose those capabilities if you do these mods.
Click to expand...
Click to collapse
I entirely agree. Although ADB is fantastic and I absolutely love it, it's good to still have the USB mounting option instead.
The post you replied to was actually pointed toward Renate, so yeah.
---------- Post added at 02:50 PM ---------- Previous post was at 02:48 PM ----------
David0226 said:
It is a little harder to set up, but adb usb has been available in the Nook since it was first rooted. This is just one of the multiple threads here that gives instructions....
Getting USB-enabled ADB working
Click to expand...
Click to collapse
Thanks for the link - this topic has given me grief for the whole month, as I just can't seem to get the danged thing working! :laugh:
thenookieforlife3 said:
Thanks for the link - this topic has given me grief for the whole month, as I just can't seem to get the danged thing working! :laugh:
Click to expand...
Click to collapse
Good luck. My experience is that much depends on the model you have and the rooting method used. I have an original NST on which ADB over USB works without an issue. I also have a NST with Glowlight (rooted with NookManager) that I can't seem to get it working on. (I can't remember how I rooted the NST, it was a couple of years ago.)
David0226 said:
Good luck. My experience is that much depends on the model you have and the rooting method used. I have an original NST on which ADB over USB works without an issue. I also have a NST with Glowlight (rooted with NookManager) that I can't seem to get it working on. (I can't remember how I rooted the NST, it was a couple of years ago.)
Click to expand...
Click to collapse
AH! Good to know! I thought that I was just being a dumbo not being able to get ADB USB working (I have an NSTG rooted w/NookManager), but now that I hear that you're having problems, too, maybe I won't worry so much!
Getting ADB to work should be easy, especially if you have a few devices and can see if the problem is with the device or the host.
On Windows getting ADB over USBcan be a pain. There are a few roadblocks:
Make sure that your device is using USB and not WiFi for ADB. The option is set in init.rc in uRamdisk. Use bootutil.exe to check/edit.
Getting the WinUSB driver loaded. Use the driver package from here: http://forum.xda-developers.com/showthread.php?p=49665945#post49665945
Getting ADB to recognize B&N devices. The newer adb.exe has the VID for B&N built in. The older adb.exe required fiddling with adb_usb.ini
Renate NST said:
Getting ADB to work should be easy, especially if you have a few devices and can see if the problem is with the device or the host.
On Windows getting ADB over USBcan be a pain. There are a few roadblocks:
Make sure that your device is using USB and not WiFi for ADB. The option is set in init.rc in uRamdisk. Use bootutil.exe to check/edit.
Getting the WinUSB driver loaded. Use the driver package from here: http://forum.xda-developers.com/showthread.php?p=49665945#post49665945
Getting ADB to recognize B&N devices. The newer adb.exe has the VID for B&N built in. The older adb.exe required fiddling with adb_usb.ini
Click to expand...
Click to collapse
Yep, already seen these in previous posts. Modifying uRamdisk doesn't seem to work, as I can still use wireless ADB with or without the mentioned changes. Already edited adb_usb.ini to include B&N. And, I think, already got the WinUSB driver. I'll check that, though.
As stated many times, if you can connect to ADB over WiFi then you can not connect to ADB over USB.
Renate NST said:
As stated many times, if you can connect to ADB over WiFi then you can not connect to ADB over USB.
Click to expand...
Click to collapse
Yes, I know that, too. The problem, as stated, is that I always can connect over WiFi, and never USB!
No matter what mods I apply to any system file, it's the same result!
thenookieforlife3 said:
No matter what mods I apply to any system file, it's the same result!
Click to expand...
Click to collapse
Are you modifying init.rc inside uRamdisk? (Not the one that appears in the root after you have booted.)
What about default.prop in uRamdisk?
Do you see a 5555 anywhere?
Are you using some amazing-super-duper-ADB-instant-turn-on-offer-application?
Well, don't.
Renate NST said:
Are you modifying init.rc inside uRamdisk? (Not the one that appears in the root after you have booted.)
What about default.prop in uRamdisk?
Do you see a 5555 anywhere?
Are you using some amazing-super-duper-ADB-instant-turn-on-offer-application?
Well, don't.
Click to expand...
Click to collapse
Answer 1: Yes, I most definitely am. In fact, I am using your bootutil.exe program to do it.
Answer 2: Yes, I also edited that to match what you wrote in the Minimal rooting - back to basics thread.
Answer 3: Yes, in the line of code
Code:
setprop service.adb.tcp.port 5555
It doesn't matter if I comment it out, it still connects wirelessly.
Answer 4: Yes, I am. But if I don't use one, then how will I turn ADB on or off?

HOWTO: Linux on Nook HD+ using native framebuffer (No VNC)

methods for booting a full linux distro on phones and tablets have existed nearly as long as Android itsself, and they almost always involve running a VNC server on a chrooted linux install and a VNC client on the host system. And the results were always virtually unusable because of how slowly it would run.
depending on what hardware your android device has, linux drivers have been included in the kernel recently enabling access to the graphics framebuffer on many common android systems.
Using the info found here as a starting point, I've adapted this to work on the Nook HD+ (and I'd imagine it would work relatively the same on the HD).
1) install Cyanogenmod
The stock firmware just isn't going to hack it. You're going to need a full Android system with a modern kernel in order to chroot into a "guest" Linux system.
2) Partition your sdcard
now, this is arguably not necessary but at a bare minimum, Linux requires a native filesystem, eg; Ext4. Yes, it could be argued that you could create a space for your Linux install on the EMMC, but for my purposes I used an ext4 partition on an external SD card.
There are quite a few ways that you can partition your SD card. The easiest would be to just do it using either CWM or TWRP. But, seeing as how you're going to need to mount the SD card on a computer in order to get a Linux system onto the new ext partition, you might as well just do it using Gparted, Disks (aka Palimpsest) or other Linux partitioning software.
I'm doing it from my macbook using OSXFuse and FUSE-ext2, so... there is more than one way to skin a cat.
3) "install" Linux
Instead of taking the time to grab one of the ARM netboot images of some distro and taking the time to build a system using Qemu (since at this point I don't have a working Linux install on my tablet), I figured it would be much easier to just download a premade system image that's already configured to run on Android... the ones I mentioned earlier when discussing accessing a host system via VNC.
Debian is my distro of choice and the "Linux-on-Android" project hosts preconfigured Debian-ARM builds. WIN! Grab the latest image (v4 at the time of writing) here:
http://sourceforge.net/projects/linuxonandroid/files/Debian/Image/Small/
Unzip the file. inside will be disk image named 'debian.img'. Mount the disk image. On Mac OS X, you can just double click the image and it will be mounted. On Linux you have a little more work to do.
Code:
sudo -s
mkdir -p /mnt/debian
mount -o loop -t ext2 /path/to/debian.img /mnt/debian
once the image is mounted, you need to copy all files from the disk image to your ext4 partition. This will have to be executed AS ROOT (sudo will NOT cut it) and you need to make sure to preserve file attributes, ownership and permissions while copying. The command will be
Code:
su
cp -vpR /mnt/debian/ /path/to/ext4partition
This is going to take a VERY long time. Even though it's less than 2gb of data, it is hundres of thousands of individual files which take a long time to process.
One the cp completes, you will be almost ready to put the card into your Nook HD+ and fire up some Linux
4) Modify xorg.conf
first and foremost you need to modify your /etc/X11/xorg.conf as follows
Code:
Section "ServerLayout"
Identifier "Layout0"
Screen "Screen0"
InputDevice "Touchscreen0" "CorePointer"
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "InputDevice"
Identifier "Touchscreen0"
Driver "evdev"
Option "Device" "/dev/input/event2"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "evdev"
Option "Device" "/dev/input/event4"
Option "Protocol" "usb"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "evdev"
Option "Device" "/dev/input/event5"
Option "Protocol" "usb"
EndSection
Section "Device"
Identifier "Card0"
Driver "fbdev"
Option "fbdev" "/dev/graphics/fb0"
VendorName "Unknown"
BoardName "Unknown"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1024x600_60.00"
EndSubSection
EndSection
Section "ServerFlags"
Option "AutoAddDevices" "false"
EndSection
5) Script to launch Linux
I've never had any luck running these commands from the Nook itsself, it must be done via ADB shell.
Code:
setprop ctl.stop media
setprop ctl.stop zygote
setprop ctl.stop surfaceflinger
setprop ctl.stop drm
stop bootanim
mount -o remount, rw /
mkdir /mnt/linux
mount -t ext4 /dev/block/mmcblk1p2 /mnt/linux
export mnt=/mnt/linux
mount -o bind /dev $mnt/dev
mount -t devpts devpts $mnt/dev/pts
mount -t proc none $mnt/proc
mount -t sysfs sysfs $mnt/sys
export PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:$PATH
export TERM=xterm
export HOME=/root
export USER=root
chroot $mnt /bin/bash
startx &
the first five commands kill conflicting Android processes, not the least of which being the Android framebuffer. Then the root directory is mounted as read/write, a temporary directory '/mnt/linux' is created (it will need to be recreated every time the tablet reboots), and then assuming your sdcard's ext4 partition is the second partition (mmcblk1p2) is mounted to the new directory, various system components are bound to the host system, a chroot environment is created and chrooted into, and finally, the Xserver is kicked off. In a few seconds, you will see the XFCE desktop begin loading on your Nook HD+.
A few notes/caveats:
although configured what I deem to be correctly, the touchscreen is not working. Strangely enough, if you issue the command
od of /dev/input/event2, you will see debug information kicked to stdout when touching the screen, so the evdev driver sees the touchscreen, but something is not quite right. For now, you can use a female to female USB adapter with the Nook's proprietary plug to connect a usb keyboard and mouse. AFAIK, USB host mode is included and works OOB on the Cyanogenmod kernel.
Since I don't own such an adapter, I've only been able to connect to the system using x11vncserver. by default, I think tightvncserver is installed and configured to use DISPLAY:1 (configured this way for the older VNC only method). After the first time, you should be able to set up some other solution like x2x or synergy in lieu of a USB keyboard and mouse.
I've had no luck getting a connected bluetooth keyboard to work with this setup. perhaps once booted and connected to the debian system installing the Linux bluetooth stack will enable full bluetooth connectivity?
This is very cool thanks for the tutorial. I am going to try this soon.
jpisini said:
This is very cool thanks for the tutorial. I am going to try this soon.
Click to expand...
Click to collapse
I've yet to be able to do anything other than start a vnc server, connect to it from a remote system and move the mouse around. the desktop seems unresponsive and doesn't finish loading most of the time. I'm digging into it to figure out what's going on.
EDIT 8/13/14
I had some success with this! First things first. the only way I can reliably control the tablet is by using a USB keyboard and mouse. I picked up a pair of USB female to female adapters for $7 on amazon. Then you need to install USB Host Switcher to force your tablet into host mode http://nook.rootshell.ru/hd/USBHostSwitcher.apk
Turn USB host mode on, connect a mouse and keyboard and test. (I have a Logitech K400r which has both keyboard and a built in trackpad)
Then, since you are not going to be able to ADB over USB any longer, enable ADB over WiFi. Then on your computer, open a terminal/cmd.exe window and connect to your tablet
adb connect 192.168.0.10:5555 (substituting your tablet's wifi IP)
Then you need to edit your xorg.conf file. The edit is simply to remove the mouse and keyboard entries because they should be probed automatically by the kernel and don't need to be explicitly defined. At least on a modern Debian system. I can't speak for other distros like Arch.
Then, once you have edited your xorg.conf file, you can begin an X session. I've been trying to set up a standard user and GDM, but haven't had much luck yet. I will update the first post when I get more bugs worked out.
very interesting projet.
I suppose that is the same setup for Nook HD?
tebra said:
very interesting projet.
I suppose that is the same setup for Nook HD?
Click to expand...
Click to collapse
yes, since hardware wise, the HD and the HD+ are pretty much identical. The biggest issue I had was getting it connected to a mouse and keyboard. Since configuration of plug n play devices is handled automatically in the kernel for most USB devices, deleting the entries for mouse and keyboard did the trick. When i get some more free time, I'm going to look into getting bluetooth and the touch screen working. I've been able to get feedback from od /dev/input/event4 for the touchscreen but no activity with the mouse. I think the issue in both cases with bluetooth and touch screen is the fact that the debian system I'm running is Lenny, which is two major releases old. Debian 8 "Jessie" is in testing currently and Debian 7 "Wheezy" is the current stable. Using the prebuilt image from the Linux on Android project worked alright as a proof of concept, but I think that we just need something running a more modern kernel and kernel modules for later hardware support. The only real path forward is going to be to build a current Debian ARMHF image. Since I'm having constant problems with the chrooted linux system locking up, the only way to build the image is going to be to use Qemu and start from a netboot image, cherry picking packages to create a minimally functional system. It's probably going to take a while.

Binding a tcp port to a block device ?

@Zaphodspeaks
Z,
okay i found a lead here http://stackoverflow.com/questions/...-android-device-failing-to-bind-tcp-port-5037
Android enforces its Internet Permission via a modification to the Linux Kernel which checks that a process is a member of an associated unix group before allowing it to open sockets in the AF_INET domain.
Such membership is inherited, so native code executed, either as a JNI library or by invoking a distinct executable, will only be able to perform network operations if it is either run as a privileged user automatically having this membership (such as adb's "shell" account, or as root on an engineering build) or run under the identify of an application package having the Internet permission in its manifest.
Click to expand...
Click to collapse
i'm going to snoop around the source and se if i can figure out how to tweak android tools source to build a modded adb and daemon and try it out.
interesting side note, even without root as long as adb is insecure you can push and run certain scripts and binaries seemingly outside of security if you work out of /data/local/tmp
for anyone wondering i had a though that maybe i could use the tab's in-house adb to connect to "itself" and achieve a root prompt.
m
EDIT- I found Q&A !!! i think ? umm this is q&a right? xD
This looks promising and fascinating.. If you pull this off, I think you will be the first to ever of done anything like this..
Zaphodspeaks said:
This looks promising and fascinating.. If you pull this off, I think you will be the first to ever of done anything like this..
Click to expand...
Click to collapse
I'd like to try it, i've been working with some simple c programming execises for the last few days
trying to figure out how to get certain system calls to work for miscellanious hooliganery! xD
i found out if you run /init in terminal you will reboot your device to recovery.
i have to re-flash a clean instance of the lp 5.1.1 firmware and then the unsecured boot.img so selinux is still intact,
then push a copy of the init binary to /data/local/tmp via adb and execute it.
if it works , then i have some neat ideas!
m
edit- i also have a new boot image which automatically mounts my debian chroot and exports the $PATH to my gcc
to anyone who needs to mount a custom block device
you need an entry like this in init.environ.rc
# Debian CHROOT
export DEBIAN_ROOT /debian
export TMPDIR /tmp
mount -t proc none /debian/proc
mount -t sysfs none /debian/sys
mount -o bind /dev /debian/dev
mount -o bind /proc/net /debian/proc/net
mount -t devpts none /debian/dev/pts
[this is for mounting my chroot, so all i have to do is run the chroot command itself and all my needed mounts are already in place]
and amend your path and ld library entries
export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/gcc/bin:/system/xbin:/bin:/usr/bin:/usr/sbin
export LD_LIBRARY_PATH /system/lib:/system/gcc/lib:/system/vendor/lib
NOTE TO SELF- pipe the output of strace <command> to text
strace id &> narc.txt
moonbutt74 said:
I'd like to try it, i've been working with some simple c programming execises for the last few days
trying to figure out how to get certain system calls to work for miscellanious hooliganery! xD
i found out if you run /init in terminal you will reboot your device to recovery.
i have to re-flash a clean instance of the lp 5.1.1 firmware and then the unsecured boot.img so selinux is still intact,
then push a copy of the init binary to /data/local/tmp via adb and execute it.
if it works , then i have some neat ideas!
m
Click to expand...
Click to collapse
Damn I wish I had your skills.. Programming is NOT my forte.... Hardware repair and PC diagnostics is what I'm best at..
@Zaphodspeaks
OKAY,
stumbled across something interesting, this will be slightly interrupted as i need to switch to tab for the second part of the post,
[via adb shell]
strace adb shell
one line in particular caught my notice in the output of strace
Code:
connect(3, {sa_family=AF_FILE, path="[COLOR="Red"]/tmp/5037[/COLOR]"}, 12) = 0
back in a minute... okay, i'm on tab from clean reboot,
when running adb shell [remember the above] i get this
Code:
[email protected]:/ # adb shell
* daemon not running. starting it now on port 5038 *
* daemon started successfully *
error: device not found
1|[email protected]:/ #
okay now [with unsecured boot.img] as normal user in tab you cannot do this part, BUT you can via adb shell on pc-side
Code:
mkdir /data/local/tmp/5038
EDITED - see edit below [dammit, i really have to start taking notes]
EDIT
that's maybe a "HIT" of some kind. How to make it work from there i'm not sure yet.
okay i goofed by mkdir 5038 should actually be a link to socket [DERP]
i'll get back to this after some breakfast so as to avoid brain death from overcaffination. xD
i had to edit this, i lost a step somewhere, should have posted all of this from the first time around
I'm trying to understand sockets and pipes, yay!
m
okay
i learnded me how to create a symlink to a socket
ln socket:[5038] /blah-blah/5038 [sort of ]
i'm guessing i need to be looking at how /proc works
for an example in /proc/5743/fd
10 -> socket:[41910]
from http://www.linuxquestions.org/quest...an-i-create-a-socket-file-248399/#post4398605
Lots of misunderstanding here; let's see if I can clarify.
A socket file is not a regular file, it's more like an IP address (it is also not a fifo, although those are similar). A socket file is created by the system when a program calls bind on a unix domain socket, which is a special kind of network socket that can only be internal to one computer. The system then associates this special file with the socket file descriptor that the program bound (or more specifically, the "inode" to which that file descriptor refers).
From that point on, the program that created the socket has no interaction with the socket by the filename. If you move it elsewhere, create new links to it, or remove it, you may confuse other programs that are trying to talk to the program in question, but the program itself won't see it at all. You are only changing the set of names that point at that inode (and you can connect to the listening program at that new name!). Thinking of the filename as a domain name, the inode as the ip address, and the filesystem as DNS isn't so very far off.
Click to expand...
Click to collapse
i'm guessing sock_create is a c thing http://linux.die.net/man/2/socket
i have authbind "working" after getting the source configured for ndk-build , but i don't yet know what a good example of it's usage would be to prove that it functions as it should.
@osm0sis,
okay, as per your instucts , i did this
[email protected]:/ # cat /sdcard/dooby
#!/system/bin/sh
cd /sdcard
setprop service.adb.tcp.port 5555
stop adbd && start adbd
adb connect 192.168.254.42
pwd
adb shell pwd
[email protected]:/ # /sdcard/./dooby
connected to 192.168.254.42:5555
/sdcard
/
[email protected]:/ #
now of i understand this correctly i am connecting to myself via my router, right?
you know, if i remount / and touch this script there and run it with a little modification i can probably create a loop, xD
Sounds fun. Glad to be of service.

Categories

Resources