Flash Magic Forum

Archive => Old Topics => Topic started by: Harshadbhai Ukani on August 30, 2004, 08:56:05 PM

Title: 89V51Security Bit.
Post by: Harshadbhai Ukani on August 30, 2004, 08:56:05 PM
Dear Andy,

I was forced to use 89V51rd2 due to availibity problem, in place of 89C51rd2.

I am using flash magic to proramm the Micro.
If I set the security bit. I am not able to reload the programme. Is there any way?

I have tried 1) RESTIING the Serial no. and 2) Erase block 0, but no recovery.

Please help

-Harshadbhai

Title: Re: 89V51Security Bit.
Post by: Andy Ayre on September 01, 2004, 09:42:44 AM
I believe that selecting "erase all flash" in section 2 of the main window should erase the security bit.

Title: Re: 89V51Security Bit.
Post by: lambros sirivlis on September 01, 2004, 11:34:47 PM
1)reset serial number.
2)erase all flash.
3)program again .
the security bit will not be erased but the chip will be programmed.
(use flash magic 2.01 or later)

Lambros Sirivlis
Title: Re: 89V51Security Bit.
Post by: Andy Ayre on September 02, 2004, 09:49:19 AM
I was wrong - the security bit cannot be erased via ISP once programmed, and Flash Magic even warns you of this. Some more information:

1. The security bit has no effect on ISP operations. It only blocks parallel programmer operations.

2. Setting the serial number AND resetting the device will stop ISP from working.

3. To use the device in ISP mode again, the serial number must be reset (which will erase the device) or the unlock feature must be used by supplying the serial number.

Title: Re: 89V51Security Bit.
Post by: Harshadbhai Ukani on September 06, 2004, 08:56:16 PM

Dear Andy,

Thanks,

It was a problem of using earlier version of Flash, Which prohibits reading, reprogramming of the device if security bit is SET. But with version 2.05 upward there is no problem with re-programming.

Now the problem is of selective erase of sectors/pages. As Flash magic is supporting it there should be ISP / IAP routines for this. But data sheet is giving any details. Will you please give the details?.

I feel that Phillips should stop reading the Flash if security bit is set, All other function (Erase / Reprogramme) should work. This will give more security to Code.

-Harshadbhai Ukani.
Title: Re: 89V51Security Bit.
Post by: Andy Ayre on September 06, 2004, 10:04:18 PM
You can achieve full security but setting the password (along with the security bit). Someone else will only be able to reset the password, which will cause the device to be erased.

Title: Re: 89V51Security Bit.
Post by: Harshadbhai Ukani on September 07, 2004, 08:20:52 PM
Dear Andy,

The problem is any password is succeptible for Crack/Theft, and if some one has the password he can read the Flash Code even if the security bit is Set.

I fail to understand the Purpose of allowing reading of the Code data through ISP even if the security bit is set.

Will you please give me details for selective erase of pages?. It is working in Flash Magic that means there is ISP for the same.

-Harshadbhai Ukani.
Title: Re: 89V51Security Bit.
Post by: Andy Ayre on September 07, 2004, 08:42:54 PM
Page erase:

:0300000308aaaacc

aaaa = page address
cc = checksum

Title: Re: 89V51Security Bit.
Post by: Harshadbhai Ukani on September 09, 2004, 10:51:11 PM
Thanks Andy,

I wanted Page erase by IAP as I have to store some data into flash(Default Parameter which very from installation to installation).

If you can have it from phillips, please pass on to me.

-Harshadbhai
Title: Re: 89V51Security Bit.
Post by: erikm on September 10, 2004, 05:11:31 AM
I wanted Page erase by IAP

It is there, pay attention the page is 64k (all of it)

Erik
Title: Re: 89V51Security Bit.
Post by: Harshadbhai Ukani on September 10, 2004, 07:55:19 PM
Dear Erik,

Sorry I wanted sector erase. The default parameters are 256 byte, a sector of 512 bytes is good enough. Erasing whole page is of no use once the application is running at customer's place.

-Harshadbhai
Title: Re: 89V51Security Bit.
Post by: erikm on September 13, 2004, 05:40:29 AM
Sorry I wanted sector erase. The default parameters are 256 byte, a sector of 512 bytes is good enough. Erasing whole page is of no use once the application is running at customer's place.

This is FLASH!!!!!!!

Erik
Title: Re: 89V51Security Bit.
Post by: S.Poduval on September 14, 2004, 01:33:57 AM
Dear Harshadbhai,


  You can erase any sector of 128 bytes.  
 
  Set DPH and DPL for the add. locs to be erased.  Make sure that bits 0-6   of DPL are zeroes.
 
  Clear bit 1 of FCF register (B1H). ( This has to be done once only after reset).

  Clear BSEL bit .  As mentioned in the data sheet ,avoid clearing BSEL bit  when the user program is operating in the range 0000-1FFFH.

  Set R1 = 08H

  Call PGM_MTP at 1FF0H

  Set BSEL bit.


S.Poduval.

Title: Re: 89V51Security Bit.
Post by: Harshadbhai Ukani on September 16, 2004, 08:41:13 PM

Dear Erik,

What do you mean by this is Flash !!!!!.

Yes this is flash and that is why we can think of erasing a sector.

-Harshadbhai


Dear S. Poduval,

Thank you very much. I was debugging the upper block and I felt that for page erase before calling PGM_MTP DPL shall have higher address and ACC should have Lower address. I have missed that for record 3 SS is higher address data is only lower address for function code 8.

Thanks a lot once again
-Harshadbhai

;
;Record no. 3
L01BC:
        JNB     008H,L014C
        ACALL   L01B8           ;Clear bit 0 to bit 7
        MOV        DPTR,#L0000
        MOV        R1,#080H
        MOV      037H,@R1        ;Sub Function
        CJNE     @R1,#007H,L01CD
        SJMP     L01E9           ;Sub function can not be 7
;
L01CD:   CJNE   @R1,#005H,L01D2
;sub function 5
        SJMP    L01DD           ;Prorgrame security bit / Dbl Clock
;
L01D2:  JB      001H,L01E7      ;?? if bit 1 set no action
        CJNE    @R1,#001H,L01DD
;sub function 1 Erase Block
   INC   R1
                MOV         DPH,@R1         ;Selection code at dph
   SJMP   L01E0
;
L01DD:   
   INC   R1
   MOV   DPL,@R1   ;This will be Higher Address in record 3
;
L01E0:
   INC   R1
   MOV   A,@R1      ;This will be Lower Address for
      MOV     R1,037H         ;Sub function in R1(1 for Erase block 8 for sector   erase)
   LCALL   L1FF0
;
L01E7:   AJMP   L0146
;
;
L01E9:   AJMP   L0146
;
Title: Re: 89V51Security Bit.
Post by: Annibal Abreu on September 25, 2004, 10:54:05 AM
Harshadbhai Ukani

Could you resume how to erase a sector ?

I mean, how would be a command for this ?
Title: Re: 89V51Security Bit.
Post by: Harshadbhai Ukani on September 26, 2004, 08:43:07 PM
Dear Annibal,
Sorry as I was out and busy in other matter, have not opened my mail, you can erase a sector by


    mov    20H,#00         ;
    setb    008h              ;

    mov    0B1H,#00
    mov    r1,#8
    mov    dptr,#Sector Address(to be erased)
    call     1ff0h
   
    mov    0b1h,#01h
   
Your programme must be executing above 2000h, while executing above code.

It is recommnaded that you after finishing you IAP call you better start a fresh, as IAP uses some registers form 30H to 35H and 80H.

-Harshadbhai.
Title: Re: 89V51Security Bit.
Post by: Annibal Abreu on September 27, 2004, 05:00:59 AM
Harshadbhai.

Just one more question:

Why these two lines are necessary ?

    mov    20H,#00
    setb    008h
Title: Re: 89V51Security Bit.
Post by: Harshadbhai Ukani on September 27, 2004, 09:20:11 PM


As such for this particular call these lines are not required but for other calls this is required., (Write serial no, Erase Serial no. etc,  For which you have to modify upper 1K block as well.)  


You may ignore for your application.

-Harshadbhai
Title: Re: 89V51Security Bit.
Post by: erikm on September 28, 2004, 05:36:02 AM
I do not recall, but somewhere there is something about erasing the serial no also erases the bootloader.

Erik
Title: Re: 89V51Security Bit.
Post by: Annibal Abreu on September 28, 2004, 06:45:41 AM
What about Software RESET

The manual says:

7.10.2 - The software reset is executed by changing FCF[1](SWF) from '0' to  '1'.

Question:

Is this FCF[1] the same BSEL bit to enter IAP mode ?

So, if I get out from IAP mode, it will cause a software reset ???

Title: Re: 89V51Security Bit.
Post by: Annibal Abreu on September 28, 2004, 09:18:14 AM
Hi.

I had receive information from Philips.

There are two differents BITS. The datasheet don't say it !

SWR = software reset bit => FCF.1 (bit 1)

BSEL = bank select bit => FCF.0 (bit 0)

After REST, the SWR bit will be set. So, in order to use IAP routines, you must clear this bit.


Memory Map;

SWR=0 and BSEL =0
   ==> 0000H - 1FFFH (block 1) and above 1FFFh (block 0)
SWR=0 and BSEL =1
   ==> 0000H - FFFFH all block 0

Other combinations for SWR and BSEL , Philips didn't tell anything.
Title: Re: 89V51Security Bit.
Post by: Harshadbhai Ukani on September 28, 2004, 08:10:51 PM

Dear Annbal

I have not tried to read a byte.
Have you enabled boot block before calling the routine.
(Mov 0B1h,#00)
After reading a byte you have to return to block 0 by setting bsl bit
(Mov    0B1h,#01h
 Your programm should be executing at the address higher then 2000h

There is no third possibility for SWR and BSEL.  If you SET SWR micro does a soft start and clears the  SWR bit. So SWR will always be '0' for normal operation.

-Harshadbhai

Dear Erik,

Erasing of serial no. does not erase Boot loader, It does erase block 0.

-Harshadbhai
Title: Re: 89V51Security Bit.
Post by: Annibal on September 29, 2004, 07:31:38 PM
Hi.

I had made a mistake.

Now I can erase Flash sectors, I can program and read bytes.

Furthermore I need to set Serial Number by IAP, in other to protect my code from copy.

I need to do using IAP.  Isp function don't serve to my application !

Does any body Knows how ?