編輯:關於Android編程
Android系統啟動階段多種快速重啟系統方法試驗記錄
筆者的系統是android4.2 A20平台,平台使用的是ext4文件系統。按我以前的經驗對於nand來說yaffs對系統突然斷電重啟會好很多。筆者一個應用需求就是,系統啟動到kernel,但是還沒到應用能處理倒車事件的時候,筆者需要快速重啟,讓系統進入boot來完成倒車功能,這也是為了快速響應倒車影像。筆者使用了好幾種重啟系統的方法,都有一些問題,有的系統雖然能重啟,但是因為文件系統由於突然掉電可能導致一些cash頁沒寫成功,在boot階段加載nand驅動的時候會去做repair,這個過程大概需要2秒多一點,對我們來說不大可靠。雖然筆者後續產品可能會使用inand來替代,但是還是把以前做過的一點事情分享給大家,大家有什麼好的方法可以分享一下。有7種方法如下:
一、使用emergency_restart();
二、handle_sysrq('u');//mountro
handle_sysrq('b');//reboot
三、sys_sync();
sys_restart_syscall();
四、sys_sync();
kernel_restart(NULL);//LINUX_REBOOT_CMD_RESTART
五、sys_sync();
sys_reboot(0xfee1dead, 0x28121969, 0x1234567,NULL);
六、sys_reboot(0xfee1dead,0x28121969, 0x1234567, NULL);
加載內核過程中執行得話,系統crash;
七、直接寫watchdog的寄存器搞定,這樣會使得在重啟的時候boot階段會做repair,會要耽誤2秒鐘左右,這也是比較難接受的。
下面是各種方法的相應打印信息,對應如下:
1、 使用emergency_restart();
/*
* Emergency restart, callable from aninterrupt handler.
*/
[ 208.862932] BUG: using smp_processor_id() inpreemptible [00000000] code: sh/2667
[ 208.871614] caller is smp_send_stop+0x1c/0xe0
[ 208.876582] [
[ 208.887427] [
[ 208.898092] [
[ 208.907925] [
[ 208.918773] [
[ 208.929731] [
[ 208.939805] [
[ 208.949372] [
[ 208.958465] [
[ 208.968017] CPU0: stopping
[ 208.971127] [
[ 208.980867] [
[ 208.990505] [
[ 208.999916] Exception stack(0xc06c5cf0 to0xc06c5d38)
[ 209.005626] 5ce0: 0000040000000000 0fdcb000 c06c3140
[ 209.014866] 5d00: df82d640 00000000 00000000df807a80 00000000 00000000 c06d4480 00000001
[ 209.024100] 5d20: 00000000 c06c5d38 c0078ea8c00769c8 60000113 ffffffff
[ 209.031592] [
[ 209.040751] [
[ 209.050979] [
[ 209.061396] [
[ 209.071620] [
[ 209.082726] [
[ 209.093340] [
[ 209.102585] [
[ 209.111639] [
[ 209.121277] [
[ 209.130691] Exception stack(0xc06c5f68 to0xc06c5fb0)
[ 209.136407] 5f60: 00000003 01000000 0000000000000000 c06c4000 c070ba88
[ 209.145647] 5f80: c04ad9b8 c06dbfd0 4000406a 410fc07400000000 00000000 00000000 c06c5fb0
[ 209.154878] 5fa0: c000ea90 c000ea94 60000013ffffffff
[ 209.160614] [
[ 209.169866] [
[ 209.179025] [
[ 209.188350] [hotplug]: try to kill cpu:0failed!
[ 209.193552]
[ 209.195251] Restarting Linux version 3.4.39+(desheng@jeavox-server) (gcc version 4.6.3 20120201 (prerelease) (crosstool-NGlinaro-1.13.1-2012.02-20120222 - Linaro GCC 2012.02) ) #288 SMP PREEMPT Wed Dec11 11:39:14 HKT 2013
[ 209.195302]
[ 209.219501]sun7i_restart: to check
2、handle_sysrq('u');//mountro
handle_sysrq('b');//reboot
[ 66.797544] SysRq : Emergency Remount R/O
[ 66.808076] SysRq : Resetting
[ 66.811477] CPU0: stopping
[ 66.814617] [
[ 66.824341] [
[ 66.833966] [
[ 66.843365] Exception stack(0xd358be90 to0xd358bed8)
[ 66.849058] be80: df4e1b70 0000000000000000 df4e1c1c
[ 66.858295] bea0: de986878 df4e1b70 df4c8620df4e1bb0 df4e1c40 dfa6cfc4 dfa6cfc0 00000000
[ 66.867514] bec0: 00000000 d358bed8 c00e9c38c00e107c 20000013 ffffffff
[ 66.875006] [
[ 66.883559] [
[ 66.892706] [
[ 66.903042] [
[ 66.913251] [
[ 66.923765] [
[ 66.934668] [
[ 66.945094] [
[ 66.954422] [
[ 66.963835] [hotplug]: try to kill cpu:0failed!
[ 66.969061]
[ 66.970759] Restarting Linux version 3.4.39+(desheng@jeavox-server) (gcc version 4.6.3 20120201 (prerelease) (crosstool-NGlinaro-1.13.1-2012.02-20120222 - Linaro GCC 2012.02) ) #284 SMP PREEMPT Tue Dec10 17:32:11 HKT 2013
[ 66.970810]
[ 66.994836] sun7i_restart: to check
3、 sys_sync();
sys_restart_syscall();
重啟不了
4、sys_sync();
kernel_restart(NULL);//LINUX_REBOOT_CMD_RESTART
重啟的時候太慢,有異常,卡了幾秒鐘,太慢了。
126.005206]drivers/cpufreq/cpufreq.c:reboot_notifier_call: stop none boot cpus
[ 126.016497] CPU1: shutdown
[ 126.019916] [hotplug]: cpu(0) try to killcpu(1)
[ 126.026327] [hotplug]: cpu1 is killed!
[ 126.038924]drivers/cpufreq/cpufreq.c:reboot_notifier_call: stop none boot cpus done
[ 126.168999] codec active: 0
[ 126.172113] rest looping: 100
[ 126.788816] sunxi_rtc_setaie(222): para 0
[ 126.793314] WRN:L573(drivers/usb/host/ehci_sun7i.c):ERR:sw_ehci is disable, need not shutdown
[ 126.802944] [sw-ohci1]: ohci shutdown start
[ 126.807616] [sw-ohci1]: close clock
[ 126.811521] [sw-ohci1]: ohci shutdown end
[ 126.815988] [sw-ehci1]: ehci shutdown start
[ 126.821212] [sw-ehci1]: Set USB Power OFF
[ 126.825691] __set_vbus
[ 126.828320] [sw-ehci1]: close clock
[ 126.832266] [sw-ehci1]: ehci shutdown end
[ 126.836801] wrn: hcd is disable, need notshutdown
[ 126.842942] pmu_shutdown_chgcur = 1000000
[ 126.848055] [NAND]shutdown
[ 131.948829] nand try to shutdown 10 time
[ 131.995235] Nand flash shutdown ok!
[ 131.999177] devices shutdown time: 5948ms
[ 132.003641] Disabling non-boot CPUs ...
[ 132.007910] Restarting system.
[ 132.011326]
[ 132.012987] Restarting Linux version 3.4.39+(desheng@jeavox-server) (gcc version 4.6.3 20120201 (prerelease) (crosstool-NGlinaro-1.13.1-2012.02-20120222 - Linaro GCC 2012.02) ) #290 SMP PREEMPT Wed Dec11 17:03:17 HKT 2013
[ 132.013004]
[ 132.036965] sun7i_restart: to check
在啟動過程中,IRQ中斷handler裡面執行得好,系統會crash。
6.537818] WARNING: at kernel/softirq.c:159local_bh_enable_ip+0x4c/0xcc()
[ 6.537827] Modules linked in: mali(O) lcddisp nand(O)
[ 6.537874] [
[ 6.537898] [
[ 6.537919] [
[ 6.537942] [
[ 6.537965] [
[ 6.537988] [
[ 6.538014] [
[ 6.538039] [
[ 6.538062] [
[ 6.538084] [
[ 6.538105] [
[ 6.538127] [
[ 6.538150] [
[ 6.538170] [
[ 6.538189] [
[ 6.538202] Exception stack(0xc06c5f68 to0xc06c5fb0)
[ 6.538216] 5f60: 00000003 01000000 0000000000000000 c06c4000 c070ba88
[ 6.538233] 5f80: c04ad9b8 c06dbfd0 4000406a410fc074 00000000 00000000 00000000 c06c5fb0
[ 6.538247] 5fa0: c000ea90 c000ea94 60000013ffffffff
[ 6.538265] [
[ 6.538285] [
[ 6.538312] [
[ 6.538324] ---[ end trace 12bae582f8d57edc]---
[ 6.538373] BUG: scheduling while atomic:swapper/0/0/0x00010002
[ 6.538381] Modules linked in: mali(O) lcddisp nand(O)
[ 6.538409] [
[ 6.538431] [
[ 6.538452] [
[ 6.538473] [
[ 6.538494] [
[ 6.538520] [
[ 6.538542] [
[ 6.538561] [
[ 6.538582] [
[ 6.538603] [
[ 6.538624] [
[ 6.538644] [
[ 6.538665] [
[ 6.538685] [
[ 6.538705] [
[ 6.538725] [
[ 6.538743] [
5、 sys_sync();
sys_reboot(0xfee1dead, 0x28121969, 0x1234567,NULL);
[ 3.874315] BUG: scheduling while atomic:swapper/0/0/0x00010002
[ 3.881006] Modules linked in:
[ 3.884451] [
[ 3.894063] [
[ 3.903869] [
[ 3.914149] [
[ 3.924923] [
[ 3.937152] [
[ 3.949082] [
[ 3.959178] [
[ 3.968395] [
[ 3.977234] [
[ 3.987022] [
[ 3.997877] [
[ 4.009705] [
[ 4.022407] [
[ 4.034335] [
[ 4.044814] [
[ 4.054329] [
[ 4.064906] [
[ 4.075481] [
[ 4.086059] [
[ 4.097016] [
[ 4.107486] [
[ 4.118154] [
[ 4.127950] [
[ 4.137353] [
[ 4.146655] Exception stack(0xc06c5f68 to0xc06c5fb0)
[ 4.152283] 5f60: 00000003 01000000 0000000000000000 c06c4000 c070ba88
[ 4.161400] 5f80: c04ad9b8 c06dbfd0 4000406a410fc074 00000000 00000000 00000000 c06c5fb0
[ 4.170518] 5fa0: c000ea90 c000ea94 60000013ffffffff
[ 4.176155] [
[ 4.185267] [
[ 4.194295] [
[ 4.203514] [
[ 4.211947] bad: scheduling from the idlethread!
[ 4.217192] [
[ 4.227381] [
[ 4.237272] [
[ 4.246589] [
[ 4.256390] [
[ 4.266676] [
[ 4.277444] [
[ 4.289662] [
[ 4.301587] [
[ 4.311680] [
[ 4.320901] [
[ 4.329726] [
[ 4.339522] [
[ 4.350392] [
[ 4.362228] [
[ 4.374932] [
[ 4.386869] [
[ 4.397347] [
6、 sys_reboot(0xfee1dead, 0x28121969, 0x1234567,NULL);
加載內核過程中執行得話,系統crash;
70.309402] SYSCALL_DEFINE4: rebootmagic1=0xfee1dead, magic2=0x28121969, cmd=0x1234567
[ 70.318745]drivers/cpufreq/cpufreq.c:reboot_notifier_call: stop none boot cpus
[ 70.339919] CPU1: shutdown
[ 70.343016] [hotplug]: cpu(0) try to killcpu(1)
[ 70.349214] [hotplug]: cpu1 is killed!
[ 70.353905]drivers/cpufreq/cpufreq.c:reboot_notifier_call: stop none boot cpus done
[ 70.479995] codec active: 0
[ 70.483109] rest looping: 100
[ 71.100040] sunxi_rtc_setaie(222): para 0
[ 71.104541] WRN:L573(drivers/usb/host/ehci_sun7i.c):ERR:sw_ehci is disable, need not shutdown
[ 71.114179] [sw-ohci1]: ohci shutdown start
[ 71.118851] [sw-ohci1]: close clock
[ 71.122756] [sw-ohci1]: ohci shutdown end
[ 71.127226] [sw-ehci1]: ehci shutdown start
[ 71.132254] [sw-ehci1]: Set USB Power OFF
[ 71.136716] __set_vbus
[ 71.139340] [sw-ehci1]: close clock
[ 71.143240] [sw-ehci1]: ehci shutdown end
[ 71.147775] wrn: hcd is disable, need notshutdown
[ 71.153941] pmu_shutdown_chgcur = 1000000
[ 71.159055] [NAND]shutdown
[ 76.259791] nand try to shutdown 10 time
[ 76.302211] Nand flash shutdown ok!
[ 76.306122] devices shutdown time: 5937ms
[ 76.310613] Disabling non-boot CPUs ...
[ 76.315034] Restarting system.
[ 76.318435]
[ 76.320121] Restarting Linux version 3.4.39+(desheng@jeavox-server) (gcc version 4.6.3 20120201 (prerelease) (crosstool-NGlinaro-1.13.1-2012.02-20120222 - Linaro GCC 2012.02) ) #292 SMP PREEMPT Wed Dec11 17:38:15 HKT 2013
[ 76.320138]
[ 76.343958] sun7i_restart: to check
8.891894] WARNING: at fs/sysfs/dir.c:508sysfs_add_one+0x78/0x98()
[ 8.899237] sysfs: cannot create duplicatefilename '/class/custom_design'
[ 8.907153] Modules linked in:custom_design_drv(+) sunxi_csi0 ov7725 camera videobuf_dma_contig videobuf_coresecurity_system ektf2k mali(O) lcd disp nand(O)
[ 8.923458] [
[ 8.934210] [
[ 8.950510] [
[ 8.960708] [
[ 8.974839] [
[ 8.984705] [
[ 8.998438] [
[ 9.010851] [
[ 9.021160] [
[ 9.031540] [
[ 9.044078] [
[ 9.056658] [
[ 9.067287] [
[ 9.082747] ---[ end trace a90fd0205139c366]---
[ 9.087932] ------------[ cut here]------------
[ 9.098729] WARNING: at lib/kobject.c:198kobject_add_internal+0x150/0x1c8()
[ 9.106623] kobject_add_internal failed forcustom_design with -EEXIST, don't try to register things with the same name inthe same directory.
[ 9.132884] Modules linked in:custom_design_drv(+) sunxi_csi0 ov7725 camera videobuf_dma_contig videobuf_coresecurity_system
[ 9.145147] ###########close all layers 0,hdl 103
[ 9.151230] ektf2k mali(O) lcd disp nand(O)
[ 9.161724] [
[ 9.172531] [
[ 9.183407] [
[ 9.194411] [
[ 9.205060] [
[ 9.215317] [
[ 9.225671] [
[ 9.238418] [
[ 9.255590] [
[ 9.270886] [
[ 9.286004] ---[ end trace a90fd0205139c367]---
[ 9.291276] class_create() failed 0
[ 9.295263] init: command 'insmod' r=0
[ 9.304720] init: starting 'reversemonitor'
[ 9.352176] [TVD_INF]V4L2 device registeredas video1
[ 9.358686] init: command 'insmod' r=0
[ 9.386257] init: command 'insmod' r=0
[ 9.428488] usbcore: registered new interfacedriver asix
[ 9.434609] init: command 'insmod' r=0
[ 9.463388] usbcore: registered new interfacedriver qf9700
[ 9.469848] init: command 'insmod' r=0
[ 9.497221] usbcore: registered new interfacedriver MOSCHIP usb-ethernet driver
[ 9.505800] init: command 'insmod' r=0
[ 9.529954] usbcore: registered new interfacedriver cdc_ether
[ 9.536568] init: command 'insmod' r=0
[ 9.545432] init: processing action 0x381d0(queue_property_triggers)
[ 9.552936] init: command'queue_property_triggers' r=0
[ 9.559380] init: processing action 0x30678 (property:ro.debuggable=1)
[ 9.566925] init: starting 'console'
[ 9.571673] init: command 'start' r=0
7、直接寫watchdog的寄存器搞定,這樣會使得在重啟的時候boot階段會做repair,會要耽誤2秒鐘左右,這也是比較難接受的。
Android插件開發初探 對於Android的插件化其實已經討論已久了,但是市面上還沒有非常靠譜成熟的插件框架供我們使用。這裡我們就嘗試性的對比一下Java中,我們使用
Android中的sdcard是一個外部存儲目錄,是一個應用程序的私有目錄,只有當前應用程序有權限訪問讀寫,其他應用無權限訪問。一般用來存放一些安全性不高,但比較大的數據
本文演示:Android 界面跳轉及數據交換,通過一個小Demo展示全部過程。 效果如下所示: 1)MainActivity.java &n
1:自己最近在做了支付,遇到了一下問題先總結如下 第一條: Android快捷支付SDK Demo resultStatus={4001};memo={參數錯誤};