Nugroho's blog.: May 2013

Friday, May 3, 2013

Stuck on DFU or Recovery Mode or Connect to Itunes Logo Loop on iPhone

In the recent months, we've seen reports here and there of iPhones getting stuck in a restart loop. The black screen with the Apple logo shows up, holds for a while, and then disappears again; repeat ad infinitum. While it's not clear yet exactly what's triggering the issue (the complainants suspect that it may be a recent application update to blame), there is a tried and true way to get your iPhone, iPod touch, iPad or older iPod back to square one: either use recovery mode or do a DFU restore

DFU (Device Firmware Update) mode is a means to getting your iPhone to interface with iTunes without iTunes automatically loading the latest version of iOS onto it (it skips the iBoot bootloader, for jailbreak aficionados). Differing from recovery mode -- where iTunes restores your iPhone to its original factory settings but with the latest iOS and firmware -- DFU mode allows you to change and choose the firmware you want to install onto your iPhone. For instance, you would use DFU mode if you want to install a previous version of iOS, jailbreak your iPhone or unlock your SIM. If (for whatever reason) standard recovery isn't working for you to get your device back to working condition, DFU may help you out.

Remember, if you restore your phone in any fashion (via the iTunes 'Restore' button, recovery mode or DFU) you will lose any modifications made to unsynced content or in-app data since your last iTunes sync (game states, voice memos, notes etc.). Be cautious.

So, here's the basic info on how to enter DFU mode (and it works for your iPod touch, too). Instructions may vary slightly by year or model.

  • Connect your iPhone to your computer via USB and launch iTunes.
  • Now turn your iPhone off. Hold down the sleep / power button at the top right of your iPhone, then slide your finger across the "slide to power off" button on your iPhone's screen. (If it won't turn off, press Home and Sleep/Power until the screen goes dark, then release.)
  • Once your iPhone is off, hold down both the sleep / power button as well as the home button for 10 seconds. Once 10 seconds has elapsed, release the sleep / power button on your iPhone, but continue to hold the home button until the the above message has appeared in iTunes telling you that your iPhone has been detected in recovery mode. (If you just want to go to recovery mode, skip the 10- second hold on both buttons and simply connect the phone while holding down Home, then wait for 'Connect to iTunes' screen on the phone.)
If you see the Apple logo or the "connect to iTunes" screen on your iPhone, you're not in DFU mode. DFU leaves the screen of the iPhone completely black.

To exit DFU mode, simply hold down the sleep / power button and the home button together until your iPhone disappears from the device list in iTunes, then turn on the iPhone as normal.

Again, for most purposes (save jailbreaking) there's no practical difference between DFU and a regular restore, except and unless you're in a situation where your phone won't go into restore mode normally.

Now, what if iPhone stuck on restore loop instead of restart loop? It often happen if we upgrade the iOS.  I've tried to exit it using "just" DFU mode with no result. Apparently it needs more step, ... and it is...

While in DFU mode

  • while you plugged your iPhone and opening the itunes go to windows/system32/drivers/etc and open "hosts" file as administrator with notepad (Mac user: use Shift+Command+G and type /etc than open hosts file using TextEdit)
  • remove the last to lines with word apple in it (or add # at the begining of line)
  • safe the change
  • go to itunes shift+ restore choose the custom ipsw (Mac user: alt+ restore)
  • enjoy the restore with out any errors no 3014 or 1600 or any other error
Maybe, on Mac, we couldn't safe the change of hosts file or even worse, couldn't open it. In this case, 

open Terminal Apps
sudo cp /etc/hosts ./Desktop (enter your password)
sudo chmod 777 ./Desktop/hosts
edit hosts file in Desktop using TextEdit and safe it, back to Terminal
sudo rm /etc/hosts /etc/hostsOld
sudo cp ./Desktop/hosts /etc/hosts

Thursday, May 2, 2013

Monte Carlo PI

c calculating pi by throwing stones
PROGRAM stones
c declarations
REAL*8 area, x, y, DRAND48
INTEGER i, max, pi, seed
c set parameters (number of stones, seed for generator)
max = 1000
seed = 11168
c open file, set initial value, seed generator
OPEN(6, FILE='pif.dat')
call seed48(seed)
c execute
DO 10 i=1, max
x = DRAND48()*2-1
y = DRAND48()*2-1
IF ((x*x + y*y) .LT. 1) THEN
pi = pi+1
area = 4.0 * pi/REAL(i)
WRITE(6,*) i, area


still trying...
 program main
include "mpif.h"
double precision PI25DT
parameter (PI25DT = 3.141592653589793238462643d0)
double precision mypi, pi, h, sum, x, f, a
integer n, myid, numprocs, i, ierr
c function to integrate
f(a) = 4.d0 / (1.d0 + a*a)

call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, numprocs, ierr)

10 if ( myid .eq. 0 ) then
print *, 'Enter the number of intervals: (0 quits) '
read(*,*) n
c broadcast n
c check for quit signal
if ( n .le. 0 ) goto 30
c calculate the interval size
h = 1.0d0/n
sum = 0.0d0
do 20 i = myid+1, n, numprocs
x = h * (dble(i) - 0.5d0)
sum = sum + f(x)
20 continue
mypi = h * sum
c collect all the partial sums
c node 0 prints the answer.
if (myid .eq. 0) then
print *, 'pi is ', pi, ' Error is', abs(pi - PI25DT)
goto 10
30 call MPI_FINALIZE(ierr)

323f (5) amp (1) android (12) apple (7) arduino (18) art (1) assembler (21) astina (4) ATTiny (23) blackberry (4) camera (3) canon (2) cerita (2) computer (106) crazyness (11) debian (1) delphi (39) diary (286) flash (8) fortran (6) freebsd (6) google apps script (8) guitar (2) HTML5 (10) IFTTT (7) Instagram (7) internet (12) iOS (5) iPad (6) iPhone (5) java (1) javascript (1) keynote (2) LaTeX (6) lazarus (1) linux (29) lion (15) mac (28) macbook air (8) macbook pro (3) macOS (1) Math (3) mathematica (1) maverick (6) mazda (4) microcontroler (35) mountain lion (2) music (37) netbook (1) nugnux (6) os x (36) php (1) Physicist (29) Picture (3) programming (189) Python (109) S2 (13) software (7) Soliloquy (125) Ubuntu (5) unix (4) Video (8) wayang (3) yosemite (3)