wuhanstudio/rt-u8g2

关于使用u8g2之后无法擦除flash问题

Dozingfiretruck opened this issue · 2 comments

您好,我使用了硬件SPI的u8g2,功能正常,后来调试OTA时发现片内flash擦写失败,提示:[E/FAL] (fal_partition_erase:510) Partition erase error! Flash device(onchip_flash) erase error!
去掉u8g2线程初始化就正常擦写,后来新建工程只添加硬件SPI 和FAL,还是同样的状况,使用的是ST官方的L496ZG开发板,rtt4.0.2,最新软件包
论坛提问在这https://club.rt-thread.org/ask/question/424969.html
希望您有时间的话帮忙看一下,可能是哪里的问题,十分感谢

可能 SPI 初始化确实有些问题:
#1

SPI 初始化的代码在这里,你可以看看:

int rt_hw_spi_config(uint8_t spi_mode, uint32_t max_hz, uint8_t cs_pin )
{
rt_err_t res;
// Attach Device
spi_cs.pin = cs_pin;
rt_pin_mode(spi_cs.pin, PIN_MODE_OUTPUT);
res = rt_spi_bus_attach_device(&u8g2_spi_dev, U8G2_SPI_DEVICE_NAME, U8G2_SPI_BUS_NAME, (void*)&spi_cs);
if (res != RT_EOK)
{
rt_kprintf("[u8g2] Failed to attach device %s\n", U8G2_SPI_DEVICE_NAME);
return res;
}
// Set device SPI Mode
struct rt_spi_configuration cfg;
cfg.data_width = 8;
switch(spi_mode)
{
case 0: cfg.mode = RT_SPI_MASTER | RT_SPI_MODE_0 | RT_SPI_MSB; break;
case 1: cfg.mode = RT_SPI_MASTER | RT_SPI_MODE_1 | RT_SPI_MSB; break;
case 2: cfg.mode = RT_SPI_MASTER | RT_SPI_MODE_2 | RT_SPI_MSB; break;
case 3: cfg.mode = RT_SPI_MASTER | RT_SPI_MODE_3 | RT_SPI_MSB; break;
}
cfg.max_hz = max_hz; /* 20M,SPI max 42MHz,ssd1351 4-wire spi */
rt_spi_configure(&u8g2_spi_dev, &cfg);
return RT_EOK;
}

最近实验室事情比较多,不好意思可能没有时间调试,之后有时间我会再看看硬件 SPI 的初始化问题