1028 views|0 replies

1366

Posts

6

Resources
The OP
 

Talk about the definition of the component serial_nor--sfdp of the first-class hpm_sdk [Copy link]

 

1. Overview

In serial flash, such as NOR flash, there are many flash manufacturers and brands. For users, some operations such as sector and block erase instructions, size, etc., it is better to have unified instructions, but in fact, not all manufacturers do so. Therefore, there is an organization called JEDEC that defines a set of standards applicable to serial flash for standardization, which is the JESD216 standard.

The standard has evolved from the original JESD216 to the latest JESD216F.02. The development history and differences in versions are also listed in the protocol document, so I won’t elaborate on them here. You can download the latest JESD216 document to learn more.

In this standard, for the above instruction differences, the standard defines a table, which is the focus of this article, SFDP. This table has many para tables, and each table will describe the parameter instructions related to the flash, such as the sector erase instruction mentioned above. As long as the flash complies with the standard, the sector erase instruction can be read in the para table.

This article takes the Winbond flash and JESD216D version of W25Q64JV as an example.

II. Definition

The JESD216 standard document is 162 pages long, not too many or too few. However, if you need to define so many tables in the source code yourself, it would be a bit difficult to accept in a short period of time.

In the components of the hpm_sdk, there is a serial_nor component folder, which contains a sfdp_def.h header file. From the name, we can know that this is a definition related to sfdp. These definitions and structures can help you quickly understand its JESD216 standard.

The latest standard described in this document is JESD216D. This article will briefly explain this version.

(I) SFDP table reading

In the standard document, the beginning describes the processing of reading SFDP instructions, which can be roughly understood as follows:

1. The SFDP read instruction is 0x5A, and the corresponding macro definition in hpm_sdk is kSerialFlash_ReadSFDP

2. In the SFDP area, the address space you want to read is a three-byte field, that is, a 24-bit address.

3. Before reading data, that is, after sending the address, there must be 8 SPI clocks of dummy waiting. For example, in the case of single-line SPI reading, a byte of dummy is required. In the case of four-line reading, 4 bytes of dummy are required. (Generally, single-line SPI reading is used)

4. The SPI clock should be controlled below 50M for reading.

From the above description, we can use the spi driver of hpm to encapsulate an API interface for reading sfdp.

static hpm_stat_t hpm_spi_nor_read_sfdp(SPI_Type *ptr, uint32_t addr, uint32_t *buffer, uint32_t bytes)
{
    spi_control_config_t control_config = {0};
    uint8_t cmd = kSerialFlash_ReadSFDP;/*指令为5A*/
    /*地址设置24位*/
    ptr->TRANSFMT |= SPI_TRANSFMT_ADDRLEN_SET(sizeof(uint32_t) - 2); 
    spi_master_get_default_control_config(&control_config);
    control_config.master_config.cmd_enable = true;  /* cmd phase control for master */
    control_config.master_config.addr_enable = true; /* address phase control for master */
    control_config.master_config.addr_phase_fmt = spi_address_phase_format_single_io_mode;
    control_config.common_config.trans_mode = spi_trans_dummy_read;
    control_config.common_config.data_phase_fmt = spi_single_io_mode;
    control_config.common_config.dummy_cnt = spi_dummy_count_1;
    return spi_transfer(ptr, &control_config, &cmd, &addr, NULL, 0, (uint8_t *)buffer, bytes);
}

(II) SFDP header structure

In the standard, the address of this structure is 0x000000. The header structure includes two headers: SFDP Header and Parameter Header. There can be multiple Parameter Headers, depending on the NPH parameter of the SFDP Header. This parameter determines the number of Parameter Headers, and the parameter length of the Parameter Header determines the number of parameter tables.

Therefore, if you need to read the parameter table, you must first read the SFDP Header and Parameter Header.

1. SFDP Header

It is defined in the standard document that the structure of SFDP Header is as follows, and sfdp_def in hpm_sdk also implements the definition.

The signature is the identifier, and the ASCII value is "SFDP". This identifier needs to be read before parsing.

param_hdr_num: refers to the number of parameter headers, length + 1.

Here we need to explain the minor_rev major version. In the above, hpm has defined the version, such as JESD216D is kSfdp_Version_Minor_D.

#define kSfdp_Version_Major_1_0 (1U)
#define kSfdp_Version_Minor_0 (0U) /* JESD216 */
#define kSfdp_Version_Minor_A (5U) /* JESD216A */
#define kSfdp_Version_Minor_B (6U) /* JESD216B */
#define kSfdp_Version_Minor_C (7U) /* JESD216C */
#define kSfdp_Version_Minor_D (8U) /* JESD216D */

Where can we see these definitions? We can see the section on version differences, where we can see that, for example, JESD216B is defined as 5

2. Parameter Header

Here, sfdp_def of hpm_sdk is also defined.

There are three parameters that require explanation.

parameter_id: This is the ID value of the prameter table that indicates the specified function supported by the current flash. For example, the ID value of Basic SPI protocol indicates that the flash supports conventional SPI operations under 24-bit addresses, such as whether 1-4-4 qspi reading is supported, the capacity of the flash, the erase sector instruction, etc. This parameter can be used to know the functions supported by the flash. This parameter is divided into MSB LSB and needs to be integrated together.

This parameter can be found in the standard and is also defined in sfdp_def in hpm_sdk.

table_length_in_32bit : The number of parameter tables. Note that this is four-byte aligned. For example, if the value is 2, then 2*4=8 is required, indicating 8 parameter tables.

parameter_table_pointer[3]: indicates the 24-bit address of the parameter table to be read. All parameter tables are read from this address.

3. Parameter table

There are many tables, especially the ID that supports the Basic SPI protocol, which supports 20 words of parameters. Each word has a specified meaning. However, the sfdp of hpm_sdk is also well defined.

3. Verification

For example, take the 3rd parameter table. This table defines a 1-4-4 (cmd line, address and data four lines) read instruction: required dummy clock, required mode dummy clock, instruction value.

Then we read the table value first, and we can see:

Then we open the manual of the flash model we are operating and find the 0xeb instruction, which is the read instruction under QSPI. We can see it from the timing diagram.

This indicates that the parameters read from the sfdp table are exactly the same as the corresponding command parameters in the flas manual.

This post is from Domestic Chip Exchange
Personal signature

1084534438 欢迎交流  [加油,一切皆有可能]

 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Basic knowledge for hardware engineers

Purpose: Based on practical experience and actual projects, you will understand and master the most basic knowledge to b ...

Xinhua Dictionary of Power Supply--A brief review of the book "Basics of Power Supply Design"

Xinhua Dictionary of Power Supply - A Brief Review of the Book "Basics of Power Supply Design" When I was a child, I c ...

Is the vibration direction and wave propagation direction similar to the rhythm of the Humen Bridge?

First of all, what is a mode? A mode is the solution of Maxwell's equations without an excitation source. T is the abbr ...

What is the difference between TMS320C6416 and TMS320C6416T?

If you want to know the difference between TI DSP 6416 and 6416T, you can also use a similar method to go to TI's offici ...

【DIY Creative LED V2】Complete production steps

This post was last edited by dcexpert on 2020-10-21 15:09 The production of V2 is much simpler than V1. If everything g ...

Discussion on the Reasons for the Temperature Drop of MOS Tubes Connected in Parallel

A circuit was originally designed to test the size of AC current. The design value is 5A maximum, with multiple rang ...

37 "Ten Thousand Miles" Raspberry Pi Car——ROS Learning (VSCode Debugging ROS)

This post was last edited by lb8820265 on 2022-5-10 00:27 I have introduced VSCode debugging before , which is GDB deb ...

Can you guys give me some advice?

Last year, I switched from hardware to Linux development. At that time, I was working on drivers. When I went out for in ...

The LTC3129 chip is set to output 2.8V, why is the output 6.9V? It is strange that the size of the load resistor in the AD has not changed

The resistance value of the external resistor in the AD schematic diagram has not been modified and should be 3.3V. Why ...

[Digi-Key Follow me Issue 4] Basic Task 1: Static IP configuration, Ping, packet capture analysis, iperf speed test

> Complete the initialization of the main control board W5500 (static IP configuration), and be able to use the LAN comp ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list