S29JL032J NOR Flash Sector Address derivation

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anilsp31
Level 2
Level 2
25 sign-ins 5 replies posted 10 questions asked

We are using NOR Flash in our new product. I want to derive Sector Address as required for Protect/Unprotect function. The below shared code uses few macros for deriving the Sector Address. This code did not share the values of the macros used in this function. Can I get the values for macros used in this function?

SHORT_FLASH_SECTOR_ADDRESS, LARGE_SECTOR_SIZE, SMALL_SECTOR_SIZE

 

void flashProtectAllSectors( void )
{
Uint32 sectorAddress, saIndx;
volatile Uint16 *p; // flash pointer

// Calculate the sector offset address relative to the flash base address.
// See device datasheet Table 3. S29JL032J Sector Addresses - Top Boot Devices
for( saIndx=0; saIndx<71; saIndx++ )
{
// Note that "sectorAddress" is the sector's starting address. Values
// calculated here are as given in the aforementioned Table 3,
// column "(x8)Address Range" 000000h (SA0) through to 3FE000h (SA70)
if ( saIndx < ( ( SHORT_FLASH_SECTOR_ADDRESS & 0x3F0000 ) >> 16 ) )
{ // 32 KWords
sectorAddress = saIndx*LARGE_SECTOR_SIZE;
}
else
{ // 4K Words
sectorAddress = SHORT_FLASH_SECTOR_ADDRESS;
sectorAddress += ( saIndx - ( ( SHORT_FLASH_SECTOR_ADDRESS & 0x3F0000 ) >> 16 ) )*SMALL_SECTOR_SIZE;
}

// Device datasheet Figure 2 - In-System Sector Protect sector algorithm.
flashProtectSector( sectorAddress );

// Feedback.
printf( "Sector Protected %d \n\r", saIndx );

}// for all sectors SA0 through SA70

printf("Boot sector protect complete. Ensure 12VDC has been removed from RESET#.\n\r");
printf( "...\n\r" );
printf("\n\r");

/**NOTE NOT SHOWN --> SYSTEM PAUSED HERE TO REMOVE RESET# Vid 12VDC BEFORE PROCEEDING**/

// The 12VDC shall have been removed from RESET# at this time.
// Reset the flash (FLASH_START_ADDRESS 0x90000000)
p = ( Uint16* )FLASH_START_ADDRESS;
resetFlash(p);

} // flashProtectAllSectors

0 Likes
3 Replies
Ronak
Moderator
Moderator
Moderator
50 solutions authored 250 sign-ins 50 replies posted

Hi @Anilsp31 

Can you please let us know from where are you referring this code snippet?

Is it some code example or our Low Level Driver?

Thanks,
Ronak

0 Likes
Anilsp31
Level 2
Level 2
25 sign-ins 5 replies posted 10 questions asked

Hi Ronak,

 

You can search for query on this community. In one of the query driver source code is attached.

https://community.infineon.com/t5/Nor-Flash/FLASH-Part-Cypress-S29JL032J-In-System-Sector-Protect-Pr...

Thanks,

Anil Patil

 

0 Likes
Ronak
Moderator
Moderator
Moderator
50 solutions authored 250 sign-ins 50 replies posted

 Hi Anil,

The said code is not a part of the Infineon NOR Flash low level driver. The macros must be defined in the user project which is not attached in the thread.  Are you using the same project as the user of the thread mentioned? Can you please share us the whole code for it?

Thanks,
Ronak

0 Likes