[solved]Protecting SPI flash sectors using lib (spifi_drv_m4) LPC43

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

[solved]Protecting SPI flash sectors using lib (spifi_drv_m4) LPC43

978 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cyrilfougeray on Tue May 28 07:57:12 MST 2013

Hello everyone,


I'm porting U-Boot on SPI Flash and I'd like to protect sectors. I'm working on the Hitex LPC4350. My SPI Flash is the S25FL064P.


As I understood, there is no function provided to do this in the spifi lib. 


I try to send commands one by one but without success, here how I proceed :


<ol>
<li>Switch to commande mode (cancel_mem_mode())</li>
<li>pSpifi-&gt;cmd(0x06, 0, 0, 0); // WREN</li>
<li>pSpifi-&gt;cmd(0x01,0, 0, (*data_buf)); // write registers   /!\ Here, data is 8 bits long but cmd() use uint16_t as data. Maybe I'm configuring the config register instead of the status register...</li>
<li>Wait operation is complete</li>
<li>Write Disable</li>
</ol>

Reading the SPIFI command register after WREN returns 0xEBD30001. The most significant byte (0xEB) stands for :  Quad I/O High Performance Read. I think the pSpifi-&gt;cmd doesn't work because the cancel_mem_mode is working (I'm not able to read data then).


Is there anyone who succeed to protect sectors ? Or maybe I'm missing something ?


Thanks in advance, 


Regards


Cyril

标签 (1)
0 项奖励
3 回复数

905 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cyrilfougeray on Wed Jun 05 02:09:55 MST 2013

Some information here (see Drivers/lib/spifi_reportv0.1) :


http://www.lpcware.com/system/files/lpc18xx-2012-12-11.zip

0 项奖励

905 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cyrilfougeray on Fri May 31 07:58:20 MST 2013

For further information, 


opers.protect is two bytes long : the most significant byte determines the configuration register of the SPI flash and the least determines the status register.


You can configure these SPI Flash registers using the spifi_program function with source = dest, length = 0 and no option.


After each operation, these two registers are accessible in obj.stat.hw.

0 项奖励

905 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cyrilfougeray on Wed May 29 06:01:33 MST 2013

I found needed information for protecting my SPI flash using high level functions :


First : 


<p style="padding-left: 30px;">Serial flash devices provide write-protection in several ways. Most devices simply have 2 to 5 bits in their status registers that specify what fraction of the device is write protected, possibly in conjunction with a bit that specifies whether the fraction is at top or bottom and/or a bit that specifies whether the fraction is protected or unprotected. For such devices, at the start of spifi_program or spifi_erase the driver simply saves the status byte, then clears all of the 2 to 5 bits, so that the whole device is write-enabled. The opers.protect value of a spifi_program or spifi_erase on such a device can be 0 to leave the device fully write-enabled, -1 to restore the protection status saved at the start of the call, or any other non-zero value to set the protection status to that value. (Consult the device data sheet for the content of the latter value.)
<div>And : </div>
<div>
<div style="padding-left: 30px;">A spifi_program call with source equal to opers.dest and opers.options not including S_FORCE_ERASE will not do any erasing nor programming, since the data at opers.dest is equal to the data at source. Such a call can be used to protect or unprotect sector(s) depending on the value of opers.protect.</div>
</div>
<div>More information about how to use the lib are in the PDF.</div>
0 项奖励