How to guarantee Android auto-boot on power-up?

Started by kbro, February 03, 2014, 01:10:27 PM

Previous topic - Next topic

kbro

Last night I also noticed that the board would fully boot on DC power up if I left the USB-OTG cable to my Macbook plugged in after the power down.

I thought I'd cracked the problem until is spotted that :-)

dave-at-axon

I'm glad I am already bald headed !!  ;D

Digging through the code I found where it reads the power_start flag and displays this on the debug output.

line 165 of this file

lichee/boot/boot1/appps/Boot_Android/Board/fel_detect/fel_detect.c

As you can see, this is where it displays the value found in the script file. This is the line of code that reads this.


if(wBoot_script_parser_fetch("target", "power_start", &power_start, 1))


I also noticed that the script.bin I put in the nanda partition is not being read as the min and max recovery_key values are 40 and 4 as per the original image. My script.bin is 44 and 4

There has to be another copy of the script.bin that we can't see that is causing this.

dave-at-axon

You want the good news?

power_start=1 does work.

I decided to try my kernel and Android build again, even though it crashes on starting Android it does go into power down with the battery connected by holding down the power button.

With power-start=1 in my script.bin it does the full boot up from DC application even with the battery connected. :)

So this means that if we can somehow get the pesky board to take our modified script.bin, it will work the way we want it to.

Time for bed and a fresh start tomorrow.

Dave...

kbro

I've been testing with an SD card image.  There's good news and bad...

The good news is that the script.bin file (which is on /dev/block/mmcblk0p2) already has power_start = 1 and this has the desired effect on powerup booting with one exception - if you power down with "Quick Boot Mode next time" enabled and a battery in place, then when you apply DC power the board stops at Charging and you have to press the power button to get it to complete.  All other combinations of with/without battery and Quick Mode yes/no or "reboot -p" result in the A20 booting fully when DC power is re-applied.

The bad news is that changing script.bin in the SD card has no effect - repeating the test with power_start = 0 gives identical results.

So to my mind, the SD version suffers from the same problem as the NAND version - It doesn't read the script.bin after the first boot.

But at least we know we're on the right track with power_start.

kbro

Sorry, Dave, didn't notice your post until I'd done mine.  So we're in agreement that power_start = 1 will have the desired effect, we just need to know how to get a modified script.bin to have an effect!

dave-at-axon

We sure do.

It's all very strange. I mounted the nanda partition last night, pulled the file, made changes then rebooted the board. After it re-started I could read back the modified script.bin file so it appears to be writing the modified version but the boot sequence shows that it is not reading it as power_start is still zero.

I even have changes to add UART3 and UART4 and these are not working either.

I got an email from Allwinner before so I am going to take the chance and fire off a new one to them today about this and see if we can get some ideas why this is not working.

kbro

Here's a (daft) idea...

1. Flash a clean NAND image but do NOT reboot.
2. Boot from SD card instead.
3. Use the SD-booted image to mount the NANDA partition and tweak script.bin - therefore doing it BEOFRE the first boot
4. Boot from NAND

This ought to show whether script.bin is used first-time-only.

You could repeat the operation the other way round to modify a never-booted SD card.

I'll give it a try later today if you haven't beaten me to it - I have other stuff I'm supposed to be doing :-)

kbro

The daft idea didn't work.  I guess the SD image doesn't have the necessary stuff to define the /dev/block/nandX partitions.  I only see /dev/block/nanda, and attempts to mount that result in "invalid argument".  Looks like I need to start looking at how to build my own Android image.

dave-at-axon

Good day. I even posted on the sunxi Google group and so far have had no replies to my posting.

I've been trying to get a build to work for days now. I can build no problem (I'll document it in the next couple of days what I found) but none of the source will run on the machine. It crashes with a segment fault in the surfaceflinger.

I'd be interested to see how you get on with building the source. Just follow the information at the bottom of this page (I assume you have a Linux machine to build this on and if not, I build on a virtual machine under Windows 7 and it works fine)

https://www.olimex.com/wiki/A20-OLinuXino-MICRO

Once you have the make -j4 completed, you need to run PACK but this will fail because it can't find the board and the tar files don't include these file.

Go into lichee/tools/pack/chips/sun7i/configs/android and create a directory called olinuxino-a20

Then download this tar and copy the sys_config.fex and sys_partition.fex into that directory.

http://www.axoninstruments.biz/download/olinuxino-a20.tar.gz

pack should now run and you will have the img to put on the device. It is configured for NAND but easy to change to the SD by changing the setting in the sys_config.fex file to storage_type=1 and run pack again.

That's the settings I have been trying to use with the 7" LCD and I'd be interested to see how you get on with this and if it will run for you.

So far Olimex have not been able to provide the exact fex files for the source. Not sure why they are missing either. :)

dave-at-axon

Right, I've posted about the build process in my new blog! :)

http://axonjakarta.wordpress.com/olimex-a20-android-building/

I'll see if I can get Olimex to add this to the A20 wiki page.

dave-at-axon

OK.I've switched to the SDCARD version for now as it actually has the power_start=1 setting and it is working as expected. Applying power with battery plugged in boots up the board as long as you don't set the quick boot option.

I let the battery run down until it switched itself off and then applied DC power again and it rebooted.

This is exactly as we need it, only we need it to be working from NAND. :(

This I can work with in the mean time but I really do want to have a custom build so I can leave out stuff I don't need and set some things to default.

One thing I did notice with the SD image is that the brightness control is now in the correct direction. On the NAND version, max brightness was with the slider all the way to left. With SD it's to the normal right.


dave-at-axon

*cries*

This is very weird. I unpacked the image file using imgRePacker and I changed the sys_config.fex file to power_start=1

I then used MagicISO to open the bootloader.fex.iso file and edit the script.bin

I then repacked the img (which was now a different size) and flashed to nand... Nothing, still same power_start=0  :'(

I am running out of time with this and unless someone can get me going with the source build, I am for now going to run with the SDCARD option, albeit with a slightly slower system.

dave-at-axon

Good day.

I thought that you might like to know that I got it to work now and after some work with on the Kernel config and the Android configuration, I now have auto boot and touch working.

Olimex claim that the source files on the website are the ones used to build the image but I can tell you from all the work I had to do to add touch and the calibration alone that this is not the case. It seems to be configured for capacitive panel (I've got one coming so I will be migrating to this soon myself)

I've also now added the Mms/SMS code to my system and I can send SMS. I am still trying to get SMS receive to work but nothing yet but I am pleased with the progress so far this week. I've learned a lot about how Android is put together! :)

It's quite a lot of work to do this but I will try and get around to documenting this on my blog.

If you are interested I can upload the Android and Linux kernel for you to download if you send me a PM with your email address. I don't have enough bandwidth for all to download so I may upload to Google Drive if anyone else is interested.

You can change it easily to run from SD or NAND. I am using SD for development and once I have it where I want it, I will move to nand.

kbro

Have you come across anything in your build investigations that would suggest you have the wherewithal to create an Android image for the A10 LIME?  The official one is supposedly out Real Soon Now but it's not here yet :-)

dave-at-axon

Not without the binaries for it, no, not really possible unless the hardware is close to an existing design. Allwinner have a number of no source binaries in there that would make it impossible without a lot of rework.

For example, I am trying to get SMS receiving to work and they only have a binary for the RIL so I am trying to port a Huawei generic RIL that someone else created to the board. With luck I will get SMS fully working soon. :)