Giter VIP home page Giter VIP logo

sfud's Issues

W25Q64BV Write Enable Failed

你好,你的工具设计很不错,我尝试了下,修改def为winbod W25Q64BV,运行后发现在
“sfud_erase”中执行write enable报错,但我用其它驱动读写都没问题,说明板子是可以write enable的,看你的代码中有lock spi 然后unlock spi这个动作,不太明白为什么需要,也不清楚为什么Status Register的WEL位没有置1,请问可以帮我看看么,谢谢!

*SFUD](......\sfud\src\sfud.c:861) The flash device manufacturer ID is 0xEF, memory type ID is
0x40, capacity ID is 0x17.
SFUD Error: Check SFDP signature error. It's must be 50444653h('S' 'F' 'D' 'P').
[SFUD]Warning: Read SFDP parameter header information failed. The W25Q64BV is not support JEDEC SFDP.
[SFUD]Find a Winbond W25Q64BV flash chip. Size is 8388608 bytes.
SFUD Flash device reset success.
[SFUD]W25Q64BV flash device is initialize success.
[SFUD]Error: Can't enable write status.
Erase the W25Q64BV flash data failed.

eraser_index 未使用警告

..\SFUD\sfud\src\sfud.c(404): warning: #177-D: variable "eraser_index" was declared but never referenced

注释掉 SFUD_USING_SFDP,会出现上面的警告。不影响程序运行。

Error: Check SFDP signature error. It's must be 50444653h('S' 'F' 'D' 'P')

bsp:正点原子stm32f429-apollo W25Q256
根据Readme进行了 no os 裸机移植,
出现如下问题,请问这中问题一般是 啥原因造成的呢?
[SFUD]Error: W25Q256 flash device is initialize fail.?
SFUD The flash device manufacturer ID is 0x9F, memory type ID is 0x90, capacity ID is 0x4D.
SFUD Error: Check SFDP signature error. It's must be 50444653h('S' 'F' 'D' 'P').
[SFUD]Warning: Read SFDP parameter header information failed. The W25Q256 is not support JEDEC SFDP.
[SFUD]Warning: This flash device is not found or not support.

新添加SPI的flash无法正常工作(BY25D16)

@armink 请帮忙看下这是什么问题呢.
<00> info> app: Start initialize Serial Flash Universal Driver(SFUD) V1.1.0.
<00> info> app: You can get the latest version on https://github.com/armink/SFUD .
<00> info> app: The flash device manufacturer ID is 0x00, memory type ID is 0x00, capacity ID is 0xBD.
<00> info> app: Error: Check SFDP signature error. It's must be 50444653h('S' 'F' 'D' 'P').
<00> info> app: Warning: Read SFDP parameter header information fail<info> app: Warning: This flash device is not found or not support.
<00> info> app: Error: BY25D16 flash device is initialize fail.

在SFUD_FLASH_CHIP_TABLE的末尾已经添加了{"BY25D16", SFUD_MF_ID_BOYA, 0x40, 0x15, 2L1024L1024L, SFUD_WM_PAGE_256B, 4096, 0x20},

感谢

upport JEDEC Basic Flash ParameterDword-8

/* get erase size and erase command */
for (i = 0, j = 0; i < SFUD_SFDP_ERASE_TYPE_MAX_NUM; i++) {
if (table[28 + 2 * i] != 0x00) {
sfdp->eraser[j].size = 1L << table[28 + 2 * i];
sfdp->eraser[j].cmd = table[28 + 2 * i + 1];
SFUD_DEBUG("Flash device supports %ldKB block erase. Command is 0x%02X.", sfdp->eraser[j].size / 1024,
sfdp->eraser[j].cmd);
j++;
}
}

the offset of the table[28] replace 28->24 ,can support JEDEC Basic Flash ParameterDword-8

set_write_enabled失败,导致无法写AT45DB161

atmel这款旧的flash不支持SFDP标准,SFUD_CMD_WRITE_ENABLE和SFUD_CMD_WRITE_DISABLE这两个指令也不支持。需要注释set_write_enabled函数,直接返回SFUD_SUCCESS,才可以正常写数据。

软件复位失效

某些FLASH,例如 CYPRESS S25HL01GT 要求 发送 0x66 命令后 必须紧接着发送 0x99 命令才能复位,中间不能插入其他命令。
并且要复位后才能使用 0x9F 命令读取信息。

SFUD不支持AT45DB161E

AT45DB161E的SFUD_CMD_READ_STATUS_REGISTER为0xD7,SFUD中默认为0x05;

#ifndef SFUD_CMD_READ_STATUS_REGISTER
#define SFUD_CMD_READ_STATUS_REGISTER                  0x05
#endif

即便在sfud_cfg.h中重定义SFUD_CMD_READ_STATUS_REGISTER

#define SFUD_CMD_READ_STATUS_REGISTER 0xD7

AT45DB161E的Status Register的BUSY在bit7上,SFUD中默认在bit0;

以下两个命令在AT45DB161E也没有找到

#ifndef SFUD_CMD_WRITE_ENABLE
#define SFUD_CMD_WRITE_ENABLE                          0x06
#endif

#ifndef SFUD_CMD_WRITE_DISABLE
#define SFUD_CMD_WRITE_DISABLE                         0x04
#endif

后面应该还有命令不一样,就不继续测试了。

一些语言特性不被Keil C51支持

Keil的C编译器是基于C90的,所以有很多C99的特性不被支持导致无法编译。比如可变参数的宏定义 XXX(...) 等。
这导致51单片机全军覆没。有没有可能用一个开关来切换这些不被支持的语法,并最低限度的支持C51?

A Little Typo

There is a typo in the following debug info. Instead of NPN, it should be NPH(Number of Parameter Header), which specifies the number of parameter headers in the SFDP data structure.

SFUD/sfud/src/sfud_sfdp.c

Lines 131 to 132 in 1469249

SFUD_DEBUG("Check SFDP header is OK. The reversion is V%d.%d, NPN is %d.", sfdp->major_rev, sfdp->minor_rev,
header[6]);

AT45DB321 default page size 528

现在使用的是AT45DB321,库里支持的是AT45DB16,已经通过查询手册增加了AT45DB321,现在看到手册上说默认是528,而SFUD里面写的是512,请问一下这里有什么问题。
 User configurable page size
 512 bytes per page
 528 bytes per page (default)
 Page size can be factory pre-configured for 512 bytes

[FR]支持FastRead

有些Flash在Read模式和FastRead模式下速率差距有点大,SFUD似乎没做FastRead的支持,可能会导致某些Flash跑不到满速

image
image

STM32H723+GD25Q256不正常工作

我是用STM32H723+GD25Q256的方式,使用OSPI的4线或者1线模式可以读取sfdp信息,但是进行读写测试不能成功,读回来的数据都是0xff。请问这里大概会是什么原因呢?下面是我的port部分代码:
/*

  • This file is part of the Serial Flash Universal Driver Library.
  • Copyright (c) 2016-2018, Armink, [email protected]
  • Permission is hereby granted, free of charge, to any person obtaining
  • a copy of this software and associated documentation files (the
  • 'Software'), to deal in the Software without restriction, including
  • without limitation the rights to use, copy, modify, merge, publish,
  • distribute, sublicense, and/or sell copies of the Software, and to
  • permit persons to whom the Software is furnished to do so, subject to
  • the following conditions:
  • The above copyright notice and this permission notice shall be
  • included in all copies or substantial portions of the Software.
  • THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  • EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  • MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  • IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  • CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  • TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  • SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Function: Portable interface for each platform.
  • Created on: 2016-04-23
    */

#include <sfud.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "main.h"
#include "cmsis_os.h"

static char log_buf[256];

void sfud_log_debug(const char *file, const long line, const char *format, ...);

void sfud_log_info(const char *format, ...);
sfud_err qspi_send_then_recv(const sfud_spi *spi,const void *send_buf, size_t send_length, void *recv_buf, size_t recv_length);
extern OSPI_HandleTypeDef hospi1;

typedef struct
{
OSPI_HandleTypeDef *spix;
GPIO_TypeDef *cs_gpiox;
uint16_t cs_gpio_pin;
} spi_user_data, *spi_user_data_t;

static void spi_lock(const sfud_spi *spi)
{
//__disable_irq();
}

static void spi_unlock(const sfud_spi *spi)
{
//__enable_irq();
}
void cmdhandler_default(OSPI_RegularCmdTypeDef * Cmdhandler)
{
Cmdhandler->OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
Cmdhandler->FlashId = HAL_OSPI_FLASH_ID_1;
Cmdhandler->Instruction = 0;
Cmdhandler->InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
Cmdhandler->InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
Cmdhandler->InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;

Cmdhandler->Address = 0;
Cmdhandler->AddressSize = HAL_OSPI_ADDRESS_24_BITS;
Cmdhandler->AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
Cmdhandler->AddressMode = HAL_OSPI_ADDRESS_1_LINE;

Cmdhandler->AlternateBytes = 0;
Cmdhandler->AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
Cmdhandler->AlternateBytesSize = 0;
Cmdhandler->AlternateBytesDtrMode = HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE;

Cmdhandler->NbData = 0;
Cmdhandler->DataMode = HAL_OSPI_DATA_1_LINE;
Cmdhandler->DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;

Cmdhandler->DummyCycles = 0;
Cmdhandler->SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
Cmdhandler->DQSMode = HAL_OSPI_DQS_DISABLE;

}

/**

  • SPI write data then read data
    */
    static sfud_err spi_write_read(const sfud_spi *spi, const uint8_t *write_buf, size_t write_size, uint8_t *read_buf,
    size_t read_size) {
    sfud_err result = SFUD_SUCCESS;

    spi_user_data_t spi_dev = (spi_user_data_t) spi->user_data;

    if (write_size)
    {
    SFUD_ASSERT(write_buf);
    }
    if (read_size)
    {
    SFUD_ASSERT(read_buf);
    }

    /* reset cs pin */
    if (spi_dev->cs_gpiox != NULL)
    HAL_GPIO_WritePin(spi_dev->cs_gpiox, spi_dev->cs_gpio_pin, GPIO_PIN_RESET);

    if (write_size && read_size)
    {
    /* read data /
    qspi_send_then_recv(spi,write_buf, write_size, read_buf, read_size);
    }
    else if (write_size)
    {
    /
    send data */
    qspi_send_then_recv(spi,write_buf, write_size, NULL, NULL);
    }

    /* set cs pin */
    if (spi_dev->cs_gpiox != NULL)
    HAL_GPIO_WritePin(spi_dev->cs_gpiox, spi_dev->cs_gpio_pin, GPIO_PIN_SET);

    return result;
    }

#ifdef SFUD_USING_QSPI
/**

  • read flash data by QSPI
    */
    static sfud_err qspi_read(const struct __sfud_spi *spi, uint32_t addr, sfud_qspi_read_cmd_format *qspi_read_cmd_format,
    uint8_t *read_buf, size_t read_size) {

    sfud_err result = SFUD_SUCCESS;
    OSPI_RegularCmdTypeDef Cmdhandler;
    spi_user_data * hqspi;
    //QSPI_CommandTypeDef Cmdhandler;
    //extern QSPI_HandleTypeDef hqspi;
    hqspi = (spi_user_data *)spi->user_data;

    cmdhandler_default(&Cmdhandler);

    /* set cmd struct */
    Cmdhandler.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
    Cmdhandler.FlashId = HAL_OSPI_FLASH_ID_1;
    Cmdhandler.Instruction = qspi_read_cmd_format->instruction;

    if(qspi_read_cmd_format->instruction_lines == 0)
    {
    Cmdhandler.InstructionMode = HAL_OSPI_INSTRUCTION_NONE;
    }else if(qspi_read_cmd_format->instruction_lines == 1)
    {
    Cmdhandler.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
    }else if(qspi_read_cmd_format->instruction_lines == 2)
    {
    Cmdhandler.InstructionMode = HAL_OSPI_INSTRUCTION_2_LINES;
    }else if(qspi_read_cmd_format->instruction_lines == 4)
    {
    Cmdhandler.InstructionMode = HAL_OSPI_INSTRUCTION_4_LINES;
    }

    Cmdhandler.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
    Cmdhandler.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;

    Cmdhandler.Address = addr;
    Cmdhandler.AddressSize = HAL_OSPI_ADDRESS_24_BITS;
    Cmdhandler.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
    if(qspi_read_cmd_format->address_lines == 0)
    {
    Cmdhandler.AddressMode = HAL_OSPI_ADDRESS_NONE;
    }else if(qspi_read_cmd_format->address_lines == 1)
    {
    Cmdhandler.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
    }else if(qspi_read_cmd_format->address_lines == 2)
    {
    Cmdhandler.AddressMode = HAL_OSPI_ADDRESS_2_LINES;
    }else if(qspi_read_cmd_format->address_lines == 4)
    {
    Cmdhandler.AddressMode = HAL_OSPI_ADDRESS_4_LINES;
    }

    Cmdhandler.AlternateBytes = 0;
    Cmdhandler.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
    Cmdhandler.AlternateBytesSize = 0;
    Cmdhandler.AlternateBytesDtrMode = HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE;

    Cmdhandler.DummyCycles = qspi_read_cmd_format->dummy_cycles;

    Cmdhandler.NbData = read_size;
    Cmdhandler.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
    if(qspi_read_cmd_format->data_lines == 0)
    {
    Cmdhandler.DataMode = HAL_OSPI_DATA_NONE;
    }else if(qspi_read_cmd_format->data_lines == 1)
    {
    Cmdhandler.DataMode = HAL_OSPI_DATA_1_LINE;
    }else if(qspi_read_cmd_format->data_lines == 2)
    {
    Cmdhandler.DataMode = HAL_OSPI_DATA_2_LINES;
    }else if(qspi_read_cmd_format->data_lines == 4)
    {
    Cmdhandler.DataMode = HAL_OSPI_DATA_4_LINES;
    }

    Cmdhandler.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
    Cmdhandler.DQSMode = HAL_OSPI_DQS_DISABLE;

    HAL_OSPI_Command(hqspi->spix, &Cmdhandler, 5000);

    if (HAL_OSPI_Receive(hqspi->spix, read_buf, 5000) != HAL_OK)
    {
    sfud_log_info("qspi recv data failed(%d)!", hqspi->spix->ErrorCode);
    hqspi->spix->State = HAL_OSPI_STATE_READY;
    result = SFUD_ERR_READ;
    }

    return result;
    }
    #endif /* SFUD_USING_QSPI */

/* about 100 microsecond delay */
static void retry_delay_100us(void)
{
uint32_t delay = 2400;
while (delay--);
}

static spi_user_data spi1 = { .spix = &hospi1, .cs_gpiox = NULL, .cs_gpio_pin = NULL };
sfud_err sfud_spi_port_init(sfud_flash *flash) {
sfud_err result = SFUD_SUCCESS;

/**
 * add your port spi bus and device object initialize code like this:
 * 1. rcc initialize
 * 2. gpio initialize
 * 3. spi device initialize
 * 4. flash->spi and flash->retry item initialize
 *    flash->spi.wr = spi_write_read; //Required
 *    flash->spi.qspi_read = qspi_read; //Required when QSPI mode enable
 *    flash->spi.lock = spi_lock;
 *    flash->spi.unlock = spi_unlock;
 *    flash->spi.user_data = &spix;
 *    flash->retry.delay = null;
 *    flash->retry.times = 10000; //Required
 */

/* set the interfaces and data */
flash->spi.wr = spi_write_read;
flash->spi.qspi_read = qspi_read;
flash->spi.lock = spi_lock;
flash->spi.unlock = spi_unlock;
flash->spi.user_data = &spi1;
/* about 100 microsecond delay */
flash->retry.delay = retry_delay_100us;
/* adout 60 seconds timeout */
flash->retry.times = 60 * 10000;

return result;

}

/**

  • This function is print debug info.

  • @param file the file which has call this function

  • @param line the line number which has call this function

  • @param format output format

  • @param ... args
    */
    void sfud_log_debug(const char *file, const long line, const char *format, ...) {
    va_list args;

    /* args point to the first variable parameter /
    va_start(args, format);
    printf("SFUD ", file, line);
    /
    must use vprintf to print */
    vsnprintf(log_buf, sizeof(log_buf), format, args);
    printf("%s\n", log_buf);
    va_end(args);
    }

/**

  • This function is print routine info.

  • @param format output format

  • @param ... args
    */
    void sfud_log_info(const char *format, ...) {
    va_list args;

    /* args point to the first variable parameter /
    va_start(args, format);
    printf("[SFUD]");
    /
    must use vprintf to print /
    vsnprintf(log_buf, sizeof(log_buf), format, args);
    printf("%s\n", log_buf);
    va_end(args);
    }
    /
    *

  • This function can send or send then receive QSPI data.
    */
    sfud_err qspi_send_then_recv(const sfud_spi *spi,const void *send_buf, size_t send_length, void *recv_buf, size_t recv_length)
    {
    assert_param(send_buf);
    assert_param(recv_buf);
    assert_param(send_length != 0);

    OSPI_RegularCmdTypeDef Cmdhandler;
    spi_user_data * hqspi;
    hqspi = (spi_user_data *)spi->user_data;

    unsigned char *ptr = (unsigned char *)send_buf;
    size_t count = 0;
    sfud_err result = SFUD_SUCCESS;

    cmdhandler_default(&Cmdhandler);

    /* get instruction */
    Cmdhandler.Instruction = ptr[0];
    Cmdhandler.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
    count++;

    /* get address /
    if (send_length > 1)
    {
    if (send_length >= 4)
    {
    /
    address size is 3 Byte /
    Cmdhandler.Address = (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
    Cmdhandler.AddressSize = HAL_OSPI_ADDRESS_24_BITS;
    count += 3;
    }
    else
    {
    return SFUD_ERR_READ;
    }
    Cmdhandler.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
    }
    else
    {
    /
    no address stage */
    Cmdhandler.Address = 0 ;
    Cmdhandler.AddressMode = HAL_OSPI_ADDRESS_NONE;
    Cmdhandler.AddressSize = 0;
    }

    Cmdhandler.AlternateBytes = 0;
    Cmdhandler.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
    Cmdhandler.AlternateBytesSize = 0;

    Cmdhandler.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;

    if (send_buf && recv_buf)
    {
    /* recv data /
    /
    set dummy cycles */
    if (count != send_length)
    {
    Cmdhandler.DummyCycles = (send_length - count) * 8;
    }
    else
    {
    Cmdhandler.DummyCycles = 0;
    }

     /* set recv size */
     Cmdhandler.DataMode = HAL_OSPI_DATA_1_LINE;
     Cmdhandler.NbData = recv_length;
     HAL_OSPI_Command(hqspi->spix, &Cmdhandler, 5000);
     
     if (recv_length != 0)
     {
         if (HAL_OSPI_Receive(hqspi->spix, recv_buf, 5000) != HAL_OK)
         {
             sfud_log_info("qspi recv data failed(%d)!", hqspi->spix->ErrorCode);
             hqspi->spix->State = HAL_OSPI_STATE_READY;
             result = SFUD_ERR_READ;
         }
     }
    
     return result;
    

    }
    else
    {
    /* send data /
    /
    set dummy cycles */
    Cmdhandler.DummyCycles = 0;

     /* determine if there is data to send */
     if (send_length - count > 0)
     {
         Cmdhandler.DataMode = HAL_OSPI_DATA_1_LINE;
     }
     else
     {
         Cmdhandler.DataMode = HAL_OSPI_DATA_NONE;
     }
    
     /* set send buf and send size */
     Cmdhandler.NbData = send_length - count;
     HAL_OSPI_Command(hqspi->spix, &Cmdhandler, 5000);
     
     if (send_length - count > 0)
     {
         if (HAL_OSPI_Transmit(hqspi->spix,(uint8_t *)(ptr + count), 5000) != HAL_OK)
         {
             sfud_log_info("qspi send data failed(%d)!", hqspi->spix->ErrorCode);
             hqspi->spix->State = HAL_OSPI_STATE_READY;
             result = SFUD_ERR_READ;
         }
     }
     
     return result;
    

    }
    }

N25Q64 只能读,不能写

N25Q64 只能读,不能写,写完之后,读出来还是 0xFF,还是擦除后的状态。
M25P32 板子上同样的程序,正常读写。
请问下,这种情况,可能是什么原因呢?

SFUD在DSP的C28x上的移植问题

由于DSP的C28x的数据访问最小是16位,即在C28x上定义不了1字节类型的变量,最小只能定义2字节类型的变量,也即使用char定义的变量是占用两个字节的,这种情况下要移植SFUD的话有什么好的办法兼容吗?

Release

@armink 您好,尽管中间改动过几次了,但是SFUD 的版本在头文件里一直没有变化,期待能定期发 Release 或者打上 Tag,这样在使用的时候能看到代码变化和对应的版本号。多谢!

MX25L51245G 使能 qspi 模式之后,后续读、写操作都要用4线,目前 sfud 库的写都是 1线。

MX25L51245G 使能 qspi 模式之后,后续读、写操作都要用4线,目前 sfud 库的写都是 1线。

实测 MX25L51245G 芯片:
1、上电之后,在 sfdp 读取阶段(1线模式)正常;
2、进入 qspi 模式之后,后续命令(开启 4byte addr、write、erase等等)全部失败。

请问这个问题怎么解决比较好?
我想到的是修改 spi_write_read 函数,根据芯片 状态、配置信息 决定用 1线 还是 4线操作。

image

W25Q32JV测试sfdp成功

[7.137 637] [SFUD](../../middlewares/sfud/src/sfud.c:117) Start (SFUD) V1.1.0.
[SFUD](../../middlewares/sfud/src/sfud.c:872) The flash device manufacturer ID is 0xEF, memory type ID is 0x40, capacity
             ID is 0x16.
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:132) Check SFDP header is OK. The reversion is V1.5, NPN is 0.
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:175) Check JEDEC basic flash parameter header is OK. The table id is 0, re
            version is V1.5, length is 16, parameter table pointer is 0x000080.
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:203) JEDEC basic flash parameter table info:
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:204) MSB-LSB  3    2    1    0
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:207) [0001] 0xFF 0xF9 0x20 0xE5
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:207) [0002] 0x01 0xFF 0xFF 0xFF
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:207) [0003] 0x6B 0x08 0xEB 0x44
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:207) [0004] 0xBB 0x42 0x3B 0x08
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:207) [0005] 0xFF 0xFF 0xFF 0xFE
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:207) [0006] 0x00 0x00 0xFF 0xFF
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:207) [0007] 0xEB 0x40 0xFF 0xFF
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:207) [0008] 0x52 0x0F 0x20 0x0C
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:207) [0009] 0x00 0x00 0xD8 0x10
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:215) 4 KB Erase is supported throughout the device. Command is 0x20.
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:234) Write granularity is 64 bytes or larger.
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:245) Target flash status register is non-volatile.
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:271) 3-Byte only addressing.
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:305) Capacity is 4194304 Bytes.
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:312) Flash device supports 4KB block erase. Command is 0x20.
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:312) Flash device supports 32KB block erase. Command is 0x52.
[SFUD](../../middlewares/sfud/src/sfud_sfdp.c:312) Flash device supports 64KB block erase. Command is 0xD8.
[SFUD]Found a Winbond flash chip. Size is 4194304 bytes.
[SFUD](../../middlewares/sfud/src/sfud.c:850) Flash device reset success.
[SFUD]W25Q32JVSIQ flash device initialized successfully.

QSPI未测试,直接使用W25Q32BV的参数初始化也可以用。

#define SFUD_FLASH_DEVICE_TABLE                                                     \
    {                                                                               \
        [SFUD_W25Q32BV_DEVICE_INDEX] = {.name = "W25Q32JVSIQ", .spi.name = "SPI2", .chip = {"W25Q32BV", SFUD_MF_ID_WINBOND, 0x40, 0x16, 4L*1024L*1024L, SFUD_WM_PAGE_256B, 4096, 0x20}}, \
    }

增加 Power down 功能讨论

移植 SFUD 模块,用着很舒服。
最近考虑低功耗,需要把 flash 进入到低功耗模式,代码增加起来也很简单,但一直没想好是应该放到主 sfud 模块中,还是 port m模块中,亦或者单独增加个 misc 或 utility 模块。
毕竟 power down 不属于 sfud 核心功能。
有结果了我就提交 pull request.

AT45DB161的指令和sfud_def.h中的基本不同,实际不能支持?

一方面指令部分有一些差异,如读取状态位,包括状态位的位置
另一方面代码对于AT45DB161的支持也不完整?如sfud_write函数,实际上AT45DB161的SFUD_WM_BYTE|SFUD_WM_DUAL_BUFFER写模式会使其落入else if (flash->chip.write_mode & SFUD_WM_DUAL_BUFFER)中,而此处为未完成功能://TODO dual-buffer write mode

W25Q64FV不支持

我按照readme里面的方法尝试了一下 ,依然显示有问题
\ | /

  • RT - Thread Operating System
    / | \ 4.0.1 build Mar 12 2020
    2006 - 2019 Copyright by rt-thread team
    [SFUD] Warning: Read SFDP parameter header information failed. The W25Q64 is not support JEDEC SFDP.
    [SFUD] Warning: This flash device is not found or not support.
    [SFUD] Error: W25Q64 flash device is initialize fail.
    ERROR: SPI flash probe failed by SPI device spi20.
    msh />�[31m[E/drv.sdio] wait completed timeout�[0m

初始化时没有锁定SPI

在对 sfud_spi_port_init 完成调用,返回成功候,应该锁定SPI再进行信息状态的读操作

read_jedec_id

this function has a bug.
jedec id
0x9F dummy 0xEF 0xAA 0x21

SST25VF080B芯片支持

板子上用的这个芯片,自己加上了,分享一下
{"SST25VF080B", SFUD_MF_ID_SST, 0x25, 0x8E, 1L * 1024L * 1024L, SFUD_WM_BYTE|SFUD_WM_AAI, 4096, 0x20}, \

在IAR FOR STM8环境下的问题

形如 1<<24这种代码,虽然可以编译通过,但是会有警告提示位移超过上限。并且调试发现位移的结果是0。这会导致断言失败或条件判断错误。
目前我将上述代码改为 1L<<24可以解决问题。不知道有没有更好的办法?类似这种问题还出现在flash列表里的capacity项目,210241024在8位机环境下计算结果是0,所以同样需要在数字尾部添加L标识。还有demo函数里面的打印读取内容时,printf(%08x... 要改成 %08lx...,还有其他一些地方都是这个原因导致的。

The encoding of source code cannot be processed correctly by Git | 源代码的编码无法被 Git 正确处理

Background | 背景

Some editors automatically chose the "UTF-8" encoding when opening the "sfud/src/sfud_sfdp.c" file. In VS Code, we can see the following on line 226 of this file:
一些编辑器自动选择“UTF-8”编码来打开“sfud/src/sfud_sfdp.c”。在 VS Code 中,我们能在这个文件的第226行看到如下内容:

    //TODO ĿǰΪ 1.0 ���ṩ�ķ�ʽ������֧�� V1.5 �����ϵķ�ʽ��ȡ page size

I guess the garbled text is Chinese, so I tried to reopen the file with the "GB 2312" encoding:
我猜这些乱码实际上是中文文本,因此试着用“GB 2312”编码重新打开了这个文件:

    //TODO 目前为 1.0 所提供的方式,后期支持 V1.5 及以上的方式读取 page size

Now it's readable.
现在这些内容是可读的了。

Since modern frontend frameworks and web browsers are smart enough, we don't seem to be bothered by encoding issue on GitHub:
由于现代的前端框架与浏览器足够智能,在 GitHub 上我们似乎不会被编码所困扰:

//TODO 目前为 1.0 所提供的方式,后期支持 V1.5 及以上的方式读取 page size

Problem | 问题

Let's make some changes in "sfud/src/sfud_sfdp.c". Open the file with "GB 2312" in VS Code and add some characters like this:
在“sfud/src/sfud_sfdp.c”里做些修改吧。以“GB 2312”编码打开它并添加一些字符:

-     //TODO 目前为 1.0 所提供的方式,后期支持 V1.5 及以上的方式读取 page size
+     //TODO 目前为 1.0 所提供的方式,后期支持 V1.5 及以上的方式读取 page size 中文Chinese中文

Then, call "git diff":
接着执行“git diff”:

$ git diff --unified=0 sfud/src/sfud_sfdp.c
diff --git a/sfud/src/sfud_sfdp.c b/sfud/src/sfud_sfdp.c
index c77a755..a5f4a3c 100644
--- a/sfud/src/sfud_sfdp.c
+++ b/sfud/src/sfud_sfdp.c
@@ -226 +226 @@ static bool read_basic_table(sfud_flash *flash, sfdp_para_header *basic_header)
-    //TODO ĿǰΪ 1.0 <CB><F9><CC>ṩ<B5>ķ<BD>ʽ<A3><AC><BA><F3><C6><DA>֧<B3><D6> V1.5 <BC><B0><D2><D4><C9>ϵķ<BD>ʽ<B6><C1>ȡ page size
+    //TODO ĿǰΪ 1.0 <CB><F9><CC>ṩ<B5>ķ<BD>ʽ<A3><AC><BA><F3><C6><DA>֧<B3><D6> V1.5 <BC><B0><D2><D4><C9>ϵķ<BD>ʽ<B6><C1>ȡ page size <D6><D0><CE><C4>Chinese<D6><D0><CE><C4>

Well, these characters represented in hexadecimal are not what we expect. How to make the file encoding correctly recognized by Git?
呃,我们并不需要这些十六进制形式的字符。那么如何让 Git 正确识别文件的编码呢?

After some searching, I've found two solutions:
经过搜索,我找到了两种方法:

  • Adding working-tree-encoding=gb2312 to ".gitattributes" to make Git process source code files with the "GB 2312" encoding; | 向“.gitattributes”添加 working-tree-encoding=gb2312 使 Git 以“GB 2312”编码处理源代码文件;
  • Or, resaving source code files with the "UTF-8" encoding (I prefer). | 以“UTF-8”编码重新保存源代码文件(我更倾向于这个办法)。

Reference | 参考

Erase granularity not set correctly on non-uniform flash

Hello,

I'm using S25FL127S which does not support uniform 4k erase.

Library correctly reports via SFDP that flash chip does not supports uniform 4k erase, but it sets erase_gran and erase_gran_cmd to 4k erase anyway.

I modified library in such way that if sfdp.4k_erase is 0 then erase_gran and erase_gran_cmd is set to first eraser size which is larger than 4k, but I'm not sure if this is the correct way. I also dif not find any flags in SFDP that would tell which erase size is uniform for whole device.

Best regards

submodule管理

Hi,SFUD对于Submodule的管理遇到以下问题,
在移植SFUD时,遇到需要修改
sfud_cfg.h
sfud_flash_def.h
然而,为了不要影响的主代码,需要把inc和port文件夹单独拷贝一份到外部,然后外部指定头文件的包含路径为another/sfud_port/inc
然后git submodule add [SFUD_URL]后,发现在src中#include "../inc/sfud.h"依然包含的是自己的
sfud_flash_def.h,导致必须要修改sfud.c的头文件包含
所以,建议把sfud.c中的
#include "../inc/sfud.h"
改为
#include "sfud.h"
这样后面的工程只需要把inc和port拷贝一份,然后不影响到submodule的源码内容
把头文件路径包含到inc目录即可

添加国产SPI flash(P25Q16H) 出现问题

[SFUD] Warning: Read SFDP parameter header information failed. The P25Q16H is not support JEDEC SFDP.
[SFUD] Warning: This flash device is not found or not support.
[SFUD] Error: P25Q16H flash device is initialize fail.
ERROR: SPI flash probe failed by SPI device spi30.
rt sfud flash probe fail

JEDECID 0X85可以正常读取

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.