How to start LilDebi at boot when SD mount notification does not get sent
My Mele-A2000 is meant both as a media player (using Android) and a home server (using Debian), so I need LilDebi to start at boot.
There is a setting for this in the Preferences, available in the menu from the main screen
I don't see it. I only see an entry to start LilDebi whenever the sdcard is installed, but I don't have any sdcard installed in my machine.
Start on boot does not make sense since the "external storage" is not mounted yet, so instead it waits for the message that the external storage is mounted. That should happen on any Android device, since they all have some form of "external storage", which is sometimes internal and non-removable.
Where is your debian.img? You must have an internal SD card, since Lil Debi puts the file on the "external storage".
The Mele-A2000 has 4GB of internal nand storage, and an SD card slot. I don't have any SD card in that slot, tho. My debian.img is in /mnt/sdcard/debian.img. Apparently /mnt/sdcard is mounted from /dev/block/vold/93:80 (aka "nandk" which is also mounted on /mnt/secure/asec).
ah, ok, so that's an unusual Android device. All Android devices are supposed to have some sort of "External Storage" aka SD Card, and when that gets mounted, it should send out some kind of broadcast message. That's how the start on boot currently works, and then it also handles when the SD card is removed and put back in.
The actual boot complete broadcast gets sent before the External Storage is mounted, so its not useful for starting Lil Debi on basically all Android devices but yours. So to solve your issue, we need to answer some questions:
- when is your /mnt/sdcard mounted?
- is there a broadcast message related to that mounting?
I have no idea about these things. I'm a seasoned GNU/Linux user, but this is my first Android device (beside my daughter's tablet which, BTW, also has no sdcard because the internal storage has proved large enough for now). So I don't know when the /mnt/sdcard is mounted. I'd love to hear some info about how I could figure it out (and generally some info about how Android is organized, I find it very hard to find info about it).
I think many new devices have no physical / remove able sd card. While the external storage API may still work, I could see how you would not get a mount event notice.
Hans-Christoph Steiner [email protected] wrote:
ah, ok, so that's ana unusual Android device. All Android devices are supposed to have some sort of "External Storage" aka SD Card, and when that gets mounted, it should send out some kind of broadcast message. That's how the start on boot currently works, and then it also handles when the SD card is removed and put back in.
The actual boot complete broadcast gets sent before the External Storage is mounted, so its not useful for starting Lil Debi on basically all Android devices but yours. So to solve your issue, we need to answer some questions:
- when is your /mnt/sdcard mounted?
- is there a broadcast message related to that mounting?
Reply to this email directly or view it on GitHub: https://github.com/guardianproject/lildebi/issues/42#issuecomment-13948863
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
@n8fr8 any ideas how to handle this? I guess it would have to be something like:
- register OnBootComplete Listener to get notified when the device has booted
- check if /mnt/sdcard is mounted, if so start Lil' Debi, else go to step 3
- register listener to get notification of sdcard mount
- start lildebi
Anyone seen examples of this kind of thing in other apps? Seems likely to have odd bugs...
as a workaround for now, there are apps that allow you to launch apps based on schedules and things like boot time. I use TaskBomb for this, seems to work alright, but unfortunately its not free software.
Notice
- Omnidroid is, if I understand correctly, a free software replacement for TaskBomb
- my device (Lenovo LePad) doesn't have an external SD card, but on startup it still shows a message "Preparing SD card". The same happened on another (unbranded) tablet of mine, and when I opened it I discovered there was indeed a physical SD card mounted on the mainboard. This is just to say: probably the broadcast message does get sent even if there is no real external memory.
I tried Omnidroid but it does not have any "start at boot" kind of thing (it lets you start applications in response to particular events like battery-low, but none of them correspond to my needs, apparently).
I admit I had never tried something like that with Omnidroid... but concerning point 2), did you already test the option to start LilDebi whenever a SD card is mounted?!
Starting it when SD is mounted is not really an option: my machine does have an SD card slot but I only insert a card into it occasionally (e.g. when getting my camera's pictures).
Monnier, my conjecture is that if you enable that setting, it's going to behave as you desire, since Android sees the internal memory as an external SD. I may be wrong, but I suggest to just try, if you haven't.
As far as I know, all Android devices are required to have a "SD Card", and often that is a built-in one. Then there is an optional SD card slot, which will be labeled "External Storage" or something like that, but how that's represented depends on the ROM and carrier. If this particular device does not mount anything by default at /mnt/sdcard or /sdcard, that will confuse a lot of Android programs. On my Motorola Xoom tablet, it has a built-in "SD card" mounted at /mnt/sdcard, then it external SD card slot is mounted at /mnt/sdcard/external_sd. I just upgraded from Android 4.0.3 TeamEOS ROM to CyanogenMod 10.0 (Android 4.1.2). Now this is presented differently:
shell@android:/ $ ls -l /sdcard
lrwxrwxrwx root root 2013-03-14 23:12 sdcard -> /storage/sdcard0
shell@android:/ $ ls -l /mnt/
drwxr-xr-x root system 2013-03-14 23:12 asec
lrwxrwxrwx root root 2013-03-14 23:12 external1 -> /storage/sdcard1
drwxr-xr-x root system 2013-03-14 23:12 obb
lrwxrwxrwx root root 2013-03-14 23:12 sdcard -> /storage/sdcard0
drwx------ root root 2013-03-14 23:12 secure
lrwxrwxrwx root root 2013-03-14 23:12 usbdisk -> /storage/usbdisk
shell@android:/ $ ls -l /storage
drwxrwxr-x root sdcard_rw 2013-03-13 19:59 sdcard0
d---rwxr-x system sdcard_rw 1969-12-31 19:00 sdcard1
d--------- system system 2013-03-14 23:12 usbdisk
So the crux of the matter is that things have gotten a lot more complicated recently, and this will be tricky to represent in a way that is not confusing. For example, adding "OnBoot" support will confuse most Android users, since Lil Debi will fail to start after OnBoot since the SD Card won't be mounted yet. It seems that some devices don't send out OnMount notifications for their built-in SD Cards. Then if we add support for multiple install locations, that makes everything more complicated since LilDebi has to make sure that the right SD card is mounted when it receives OnMount notification.
Any ideas how to represent this well would be most appreciated.
I just found out that /system/etc/vold.fstab should tell you the mountpoints of the "removable storage", i.e. what we normally think of as SD cards, not the old Android definition ("External Storage" aka /mnt/sdcard).
Thanks toobaz for your suggestion, but I already tried the "start lildebi when sd card is mounted" (I enabled the option a long time ago to see if it helped, and never turned it back off). This said, your insistence prompted me to try it some more, so I plugged an SD card in my SD card slot and restarted the machine: LilDebi was not started either. So it looks like the problem is that Lilebi should be started (either when /mnt/sdcard (the internal NAND on which debian.img is located) is mounted or when /mnt/extsd (the actual (empty, in this case) SD card) is mounted) but isn't.
OK, if you had already tried sorry for insisting... evidently, as exposed by eighthave, a fix for this is not trivial as I thought.
its good you insist, this is an important and valuable feature. I think I found a good approach, how does this sound:
- the preference is called "Start Automatically"
- it registers to have a service started based on
ACTION_BOOT_COMPLETED - the service checks to see if
/debianis mounted it starts the chroot, if not it registersACTION_MEDIA_MOUNTEDandACTION_MEDIA_EJECTEDreceivers - when it receives
ACTION_MEDIA_MOUNTED, it starts the chroot - when it receives
ACTION_MEDIA_EJECTEDit stops the chroot
Sounds great. Still, I wonder why my LilDebi doesn't start when /mnt/sdcard is mounted (at boot) nor whenI insert the external SD card (mounted on /mnt/extsd or something like that).
Has this "Start Automatically" feature been implemented yet? The "start when SD card is mounted" option isn't working for me, either, on my MK808B tv stick.
Unfortunately, I haven't had the time to work much on Lil' Debi recently, so its not implemented yet. Patches welcome! I'm happy to help anyone who wants to take this on, or any other feature.
@eighthave: I have Motorola photon 4G mobile, with both Internal and External SDcard. I have kept the Debian Image in the internal memory. When ever any of the SDcard is mounted/remounted, the ACTION_MEDIA_MOUNTED is triggered and Debian is booted properly.
Excited that you are working on this @SDkie ! Is your code posted somewhere?
@monnier: build the latest code and see if it works for you.
@monnier: build the latest code and see if it works for you.
Sorry, I'm not using Android any more (for now at least).
Stefan
This is implemented in Lil' Debi 0.5! Please try it out and let us know how it works for you. There are some known kinks, like #113 .
I'm on a device with no SD card slot (Samsung GT-I9100 + CyanogenMod); I am having the same issue that lildebi (0.5.4) does not start Debian on boot. It seems that it does not receive a MEDIA_MOUNTED event during boot-up. However, after the device starts up, running
adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -n info.guardianproject.lildebi/.MediaMountedReceiver
starts up Debian as the signal is received by "MediaMountedReceiver.java". I believe the fix here would be for the code in "MediaMountedReceiver.java" to be factored out in a separate function, and have both "MediaMountedReceiver.java" and "BootCompletedReceiver.java" call upon it.
@e-c-d: can you please check what media related intents your OS generate?
@SDkie How would I go about recording the intents as they are generated at device start-up?