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

Nor Flash Forum Discussions

Anilsp31
Level 1
5 questions asked 10 sign-ins 5 sign-ins
Level 1

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
2 Replies
Ronak
Moderator
Moderator 50 replies posted 25 solutions authored First question asked
Moderator

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 1
5 questions asked 10 sign-ins 5 sign-ins
Level 1

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