Thursday, 20 December 2007

How to get rid of SoftICE mode in P89V51RD2

How to get rid of SoftICE mode in P89V51RD2.



Disclaimer:


No warranty that this will work for your device.

No liability for damages, lost devices etc.

Do everything on your onwn risk.





Assuming bootloader v4 and softice mode (consequence of :00000002FE).


  • download and install Keil uVision2 (evaluation version is enough); run it
  • download unsoftice.a51 (ref [1])
  • select Project->New Project, enter any name (e.g.
    "unsoftice"); a "select device for Target" window opens, select
    Philips->P89V51RD2, a dialog opens ("Copy Standard 8051 startuop
    code...") answer No
  • select File->Open, select unsoftice.a51; file should open
  • select Project->Components,Environments,Books, a window
    opens, in Project Components select Add Files, enter/browse
    unsoftice.a51
  • select Project->Build target, in the bottom (Outputs Window) it should write
     0 Error(s), 0 Warning(s).

  • select Project->Options for Project, Option for Project
    window opens, select tab Debug, select in the right column on top Use:
    Keil Monitor-51 driver, don't change anything else (unless the target
    device is not on COM1 - in that case modify it in the Options), click
    OK (window closes)
  • select Debug->Start/Stop debug session (in evaluation
    version a nag window EVALUATION VERSION (code limit 2k) opens, click
    OK), the windows rearrange a bit
  • select Debug-Go (nothing really happens), clicking on the red
    "Stop" button should bring a window saying something like "Can't stop
    application because serial interrupt is disabled". Click Stop
    debugging, wait for a moment until window "Connection to target lost"
    appears, click Stop Debugging.
  • you can exit Keil uVision2.




At this moment, the original state of bootloader is (hopefully) already restored.

Test:

- run your favorite terminal emulator, set 9600/8/n/1
NO_handshake. Switch CAPS LOCK ON (check led CapsLock on keyboard) and
hold U (for autorepeated capital U). Reset the target (or switch
off/on) while holding U. In a while, it should echo back the U's. Now
try typing
:020000050000f9
it should echo what you type and when typing
in the last character (="9") it should echo 2 more characters, a
fullstop and a carriage return, so the echo should look like:
:020000050000f9BF.



Now you can upgrade the bootloader to version 5 (can be found on Philips website) or try some other bootloader modification...


REF: http://www.efton.sk/t0t1/unsoftice.htm

==============
REF 1:
==============

SFCF DATA 0B1H ; Flash Configuration
SFCM DATA 0B2H ; Flash Command
SFAL DATA 0B3H ; Flash Address Low
SFAH DATA 0B4H ; Flash Address High
SFDT DATA 0B5H ; Flash Data
SFST DATA 0B6H ; Flash Status

;************************************************************************
;* MCU IAP Commands *
;************************************************************************
SFCM_SE EQU 0BH ; Sector-Erase IAP cmd
SFCM_VB EQU 0CH ; Byte-Verify IAP cmd
SFCM_PB EQU 0EH ; Byte-Program IAP cmd

;************************************************************************

ORIG_DATA EQU R6
;************************************************************************
;* MAIN PROGRAM *
;************************************************************************

org 00000h
ljmp main

org 2000h
main: mov PSW, #0 ; select register bank 0


start: anl SFCF, #10111111b ; BFh--> force IAPEN=0
; orl SFCF, #10000000b ; VIS=1
; mov SFDT, #0 ; Enter any value other than 55h
mov dptr, #1f00h ;load destination addr.
lcall sector_erase ; erase the bytes before write to them
;=====================================================================


mov a,#00h

mov dptr,#1f20h
loop:
mov ORIG_DATA, a
lcall byte_pgm ; write a byte from ACC to dest address

lcall verify_byte ; read back the byte written to destination
xrl a, ORIG_DATA ; compare with original data
jnz ERROR ; jump to ERROR if verification fails

Stop:
ajmp Stop ; end of code execution

;************************************************************************
;* IAP SUBROUTINES *
;* 1. SECTOR-ERASE *
;* 2. BYTE-PROGRAM *
;* 3. BYTE-VERIFY *
;************************************************************************

;===================================================================
; Subroutine of Sector Erase
;===================================================================
sector_erase:
orl SFCF, #40h ; enable IAP
mov SFAH, dph ; load high order address byte
mov SFAL, dpl ; load low order address byte
mov SFCM, #SFCM_SE ; issue sector erase command

busy: mov a, SFST
jb acc.2, busy ; wait until flash is NOT busy.

safety:
anl SFCF, #10111111b ; disable IAP
mov SFDT, #0 ; any value other than 55h

ret

;=====================================================================
; Subroutine of Byte Program
;=====================================================================
byte_pgm:
orl SFCF, #40h ; enable IAP
mov SFAH, dph ; set address to write a byte
mov SFAL, dpl
mov SFDT, ORIG_DATA ; store data to be programmed
mov SFCM, #SFCM_PB ; issue program-byte cmd

done?: mov a, SFST
jb acc.2, done? ; wait until byte-programming is done.
ljmp safety
;=====================================================================
; Subroutine of Byte Verify
;=====================================================================
verify_byte:
orl SFCF, #40h ; enable IAP
mov SFAH, dph ; address from where to read a byte
mov SFAL, dpl
mov SFCM, #SFCM_VB ; issue verify_byte cmd
nop
mov a, SFDT ; data is stored in ACC
ljmp safety
;=====================================================================


ERROR:
mov p1, #55h ;indicating IAP failed.

EXIT:
sjmp $



END






Powered by ScribeFire.

No comments:

Post a Comment