大家好:
我正在使用 NRF 连接 SDK,nrf916 硬件。
我同时使用 spi flash 和 mcuboot。这是我的一些配置:
fstab {
compatible = "zephyr,fstab";
lfs2: lfs2 {
compatible = "zephyr,fstab,littlefs";
mount-point = "/spi_flash";
partition = <&lfs2_part>;
read-size = <1>;
prog-size = <1>;
cache-size = <128>;
lookahead-size = <32>;
block-cycles = <100>;
};
};
&mx25l256 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
lfs2_part: partition@0 {
label = "spi_flash1";
reg = <0x00000000 0x00010000>;
};
};
};
***
flash0: flash@0 {
compatible = "soc-nv-flash";
label = "NRF_FLASH";
erase-block-size = < 0x1000 >;
write-block-size = < 0x4 >;
reg = < 0x0 0x100000 >;
partitions {
compatible = "fixed-partitions";
#address-cells = < 0x1 >;
#size-cells = < 0x1 >;
boot_partition: partition@0 {
label = "mcuboot";
reg = < 0x0 0x10000 >;
};
static void recreate_file_system(void)
{
const struct flash_area *pfa = NULL;
int rc;
unsigned int id = (uintptr_t)(m_mp->storage_dev);
rc = flash_area_open(id, &pfa);
if (rc < 0) {
LOG_WRN("can't find flash area %lu: %d", id, rc);
return;
}
LOG_ERR("%d '%s'", __LINE__, m_mp->mnt_point);
LOG_DBG("%d '%s' at 0x%x for 0x%x bytes", __LINE__, pfa->fa_dev_name,
(unsigned int)pfa->fa_off, (unsigned int)pfa->fa_size);
/* Optional wipe flash contents */
if (IS_ENABLED(CONFIG_APP_WIPE_STORAGE)) {
rc = flash_area_erase(pfa, 0, pfa->fa_size);
LOG_WRN("%d Erasing flash area ...[0x%x] ?%d", __LINE__, pfa->fa_size,
rc);
}
flash_area_close(pfa);
}
日志是:
<inf> file_e: recreate_file_system, 85 [00:00:00.230,926] <err> file_e: 94 '/spi_flash' [00:00:00.231,292] <dbg> file_e.recreate_file_system: 95 'NRF_FLASH_DRV_NAME' at 0x0 for 0xc000 bytes [00:00:00.231,903] <err> os: Exception occurred in Secure State [00:00:00.232,757] <err> os: ***** HARD FAULT ***** [00:00:00.233,551] <err> os: Fault escalation (see below) [00:00:00.234,375] <err> os: ***** BUS FAULT ***** [00:00:00.235,137] <err> os: Precise data bus error [00:00:00.235,931] <err> os: BFAR Address: 0x50008158 [00:00:00.236,816] <err> os: r0/a1: 0x00000000 r1/a2: 0x20015048 r2/a3: 0xffffffff [00:00:00.237,976] <err> os: r3/a4: 0x40039000 r12/ip: 0x80000000 r14/lr: 0x0002d7e5 [00:00:00.239,166] <err> os: xpsr: 0x01000000 [00:00:00.239,990] <err> os: Faulting instruction address (r15/pc): 0x00033a3c [00:00:00.240,997] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0 [00:00:00.242,034] <err> os: Current thread: 0x20015048 (unknown)
挂载点是'/spi_flash',没错。 但是起始地址和大小是 0x0、0xc000 , 它们是mcuboot的。
# SEGGER J-Link RTT Viewer V7.54d Terminal Log File # Compiled: 16:21:51 on Sep 28 2021 # Logging started @ 20 Dec 2021 20:41:58 00> [00:00:00.201,904] <err> spi_nor: Device id c2 20 19 does not match config c2 20 19 00> [00:00:00.203,186] <inf> lis2dh: LIS3DH: int1 on GPIO_0.00 00> [00:00:00.203,613] <inf> lis2dh: LIS3DH: int2 on GPIO_0.01 00> [00:00:00.204,711] <inf> lis2dh: bus=I2C_2 fs=2, odr=0x4 lp_en=0x0 scale=9576 00> [00:00:00.222,442] <inf> littlefs: littlefs partition at /spi_flash 00> [00:00:00.229,248] <inf> main: Cellular Gateway V1.0.0 00> [00:00:00.229,644] <inf> main: reset reason: 0x00010000. 00> [00:00:00.230,041] <inf> db: nvs init... 00> [00:00:00.230,529] <inf> file_e: recreate_file_system, 85 00> [00:00:00.230,926] <err> file_e: 94 '/spi_flash' 00> [00:00:00.231,292] <dbg> file_e.recreate_file_system: 95 'NRF_FLASH_DRV_NAME' at 0x0 for 0xc000 bytes 00> [00:00:00.231,903] <err> os: Exception occurred in Secure State 00> [00:00:00.232,757] <err> os: ***** HARD FAULT ***** 00> [00:00:00.233,551] <err> os: Fault escalation (see below)00:00:00.638,702] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0 00> [00:00:00.672,912] <err> os: Current thread: 0x20015048 (unknown) 00> [00:00:00.690,490] [1;31m<err> fatal_error: Resetting system[0m 00> 00> [00:00:00.201,904] <err> spi_nor: Device id c2 20 19 does not match config c2 20 19 00> [00:00:00.203,186] <inf> lis2dh: LIS3DH: int1 on GPIO_0.00 00> [00:00:00.203,613] <inf> lis2dh: LIS3DH: int2 on GPIO_0.01 00> [00:00:00.204,711] <inf> lis2dh: bus=I2C_2 fs=2, odr=0x4 lp_en=0x0 scale=9576 00> [00:00:00.222,442] <inf> littlefs: littlefs partition at /spi_flash 00> [00:00:00.229,248] <inf> main: Cellular Gateway V1.0.0 00> [00:00:00.229,644] <inf> main: reset reason: 0x00010000. 00> [00:00:00.230,041] <inf> db: nvs init... 00> [00:00:00.230,529] <inf> file_e: recreate_file_system, 85 00> [00:00:00.230,926] <err> file_e: 94 '/spi_flash' 00> [00:00:00.231,292] <dbg> file_e.recreate_file_system: 95 'NRF_FLASH_DRV_NAME' at 0x0 for 0xc000 bytes 00> [00:00:00.231,903] <err> os: Exception occurred in Secure State 00> [00:00:00.232,757] <err> os: ***** HARD FAULT ***** 00> [00:00:00.233,551] <err> os: Fault escalation (see below) 00> [00:00:00.234,375] <err> os: ***** BUS FAULT ***** 00> [00:00:00.235,137] <err> os: Precise data bus error 00> [00:00:00.235,931] <err> os: BFAR Address: 0x50008158 00> [00:00:00.236,785] <err> os: r0/a1: 0x00000000 r1/a2: 0x20015048 r2/a3: 0xffffffff 00> [00:00:00.237,976] <err> os: r3/a4: 0x40039000 r12/ip: 0x80000000 r14/lr: 0x0002d7e5 00> [00:00:00.239,166] <err> os: xpsr: 0x01000000 00> [00:00:00.239,990] <err> os: Faulting instruction address (r15/pc): 0x00033a3c 00> [00:00:00.240,997] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0 00> [00:00:00.242,034] <err> os: Current thread: 0x20015048 (unknown) 00> [00:00:00.259,582] [1;31m<err> fatal_error: Resetting system[0m (Connection lost) # Logging stopped @ 20 Dec 2021 20:42:09