Nios® V Processor Software Developer Handbook

ID 743810
Date 10/31/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

12.1.1.77. alt_lock_flash()

Prototype

int alt_lock_flash(alt_flash_dev * flash_info,

alt_u32 sectors_to_lock)

Commonly Called By

C/C++ programs

Device drivers

Thread-safe

No.

Available from ISR

No.

Include

<sys/alt_flash.h>

Description

Locking to range of the flash memory sectors, which protected from writing and erasing by passing the uninteger 32 bits value to the sectors_to_lock argument, where this argument depends on the specific flash device being used,and this argument value can be found in the flash device datasheet. The flash devices can be supported are shown as below:

EPCQ16, EPCQ32, EPCQ64, EPCQ128, EPCQ256, N25Q512, EPCQ512, EPCQL512, EPCQL1024

More Micron flash devices are supported in future, and being updated into this document.

Arguments

  • *flash_info: Pointer to general flash device structure.
  • sectors_to_lock: Block protection bits, including the top/bottom (TB) bit in the EPCQ or QSPI, according to the device. For example, in the EPCQ128 device, the bits are Bit4=TB Bit3=BP3 Bit2=BP2 Bit1=BP1 Bit0=BP0.

Return

  • *0 > Success
  • -EINVL > Invalid arguments
  • -ETIME > Time out and skipping the looping after 0.7 sec
  • -ENOLCK > Sectors lock failed