有个项目用到NRF52840,带蓝牙功能,需要在蓝牙处于广播状态的时候对Flash进行比较频繁的读写,但是测试过程中发现在写Flash的时候会出现SOFTDEVICE: ASSERTION FAILED,报错的PC指针是0x00014A3A,我这边的操作是需要写Flash的时候,先从原先地址读取4K内容到RAM,然后对这4K内容做修改后擦除原先Flash的4K内容,然后把RAM的4K写回去,这样来完成Flahs的修改.
这个SOFTDEVICE: ASSERTION FAILED出现的时候不是每次操作,程序每次上电后第一次操作会导致SOFTDEVICE: ASSERTION FAILED,然后程序复位,复位后再操作就能成功且不会引发SOFTDEVICE: ASSERTION FAILED,但是如果全Flash擦除并重刷固件与SOFTDEVICE以后第一次运行又会出现.
最后发现问题是操作Flash的时候每次4K的大小所需要的操作时间超过了SOFTDEVICE能接受的范围,导致SOFTDEVICE出现了ASSERTION FAILED,故修改方式是将那4K的内容先用4K擦除(只能按4K来擦),然后再分4次,每次写1K的内容,就不会再出现这种问题了.这个问题解决花了蛮多时间,特别是当FAE问有没有做比较大长度的Flash擦除的时候我竟然没想起来我的Flash写入机制是这种先读取后擦除再回写的机制,每次都写大长度的,导致可能消耗了一些没必要的时间.最后解决方法是在nordic的官方论坛上找到的.网址是这个: https://devzone.nordicsemi.com/f/nordic-q-a/40088/sd_flash_write-cause-nrf_fault_id_sd_assert
关于BLE活动与Flash操作同时进行时,Flash操作的成功率,有以下列表中的关系(总之就是BLE操作所需的时间越密集,实时性要求越高,Flash操作成功率就越低).
Bluetooth low energy activity(BLE活动) | Flash write/erase(Flash擦写操作) |
High Duty cycle directed advertising (高占空比定向广播) | Does not allow flash operation while advertising is active (maximum 1.28 seconds). In this case, retrying flash operation will only succeed after the advertising activity has finished. (广告活动时(最长1.28秒),不允许进行Flash操作。 在这种情况下,仅在广告活动完成后,重试Flash操作才会成功。) |
All possible Bluetooth low energy roles running concurrently (connections as a Central, Peripheral,Advertiser, and Scanner) (所有可能的BLE角色正在并发运行(作为中央,外围设备,广告商和扫描仪的连接)) | Low to medium probability of flash operation success Probability of success increases with: • Configurations with shorter event lengths • Lower data traffic • Increase in connection interval and advertiser interval • Decrease in scan window • Increase in scan interval Flash操作成功的可能性为中低. 成功的可能性随着以下因素而增加: •事件长度较短的配置 •较低的数据流量 •增加连接间隔和广播间隔 •减少扫描窗口 •增加扫描间隔 |
8 high bandwidth connections as a Central 1 high bandwidth connection as a Peripheral All active connections fulfill the following criteria: • Supervision time-out > 6 x connection interval • Connection interval ≥ 150 ms • All central connections have the same connection interval (8个高带宽连接作为中央设备 1个高带宽连接作为外围设备 所有活动连接均满足以下条件: •超时时间> 6 x连接间隔 •连接间隔≥150 ms •所有中央连接都具有相同的连接间隔) | High probability of flash write success Medium probability of flash erase success (High probability if the connection interval is > 240 ms) (Flash写入成功的可能性很高.Flash擦除成功的可能性中等(如果连接间隔> 240毫秒,则可能性很高)) |
8 high bandwidth connections as a Central All active connections fulfill the following criteria: • Supervision time-out > 6 x connection interval • Connection interval ≥ 150 ms • All connections have the same connection interval (8个高带宽连接作为中央 所有活动连接均满足以下条件: •超时时间> 6 x连接间隔 •连接间隔≥150 ms •所有连接具有相同的连接间隔) | High probability of flash operation success (Flash操作成功的可能性很高) |
8 low bandwidth connections as a Central All active connections fulfill the following criteria: • Supervision time-out > 6 x connection interval • Connection interval ≥ 110 ms • All connections have the same connection interval (8个低带宽连接作为中央 所有活动连接均满足以下条件: •超时时间> 6 x连接间隔 •连接间隔≥110 ms •所有连接具有相同的连接间隔) | High probability of flash operation success (Flash操作成功的可能性很高) |
1 connection as a Peripheral The active connection fulfills the following criteria: • Supervision time-out > 6 x connection interval • Connection interval ≥ 25 ms (1个连接作为外围设备 活动连接满足以下条件: •超时时间> 6 x连接间隔 •连接间隔≥25 ms) | High probability of flash operation success (Flash操作成功的可能性很高) |
Connectable Undirected Advertising Nonconnectable Advertising Scannable Advertising Connectable Low Duty Cycle Directed Advertising (连接的非定向广告 不可连接的广告 可扫描广告 可连接的低占空比定向广告) | High probability of flash operation success (Flash操作成功的可能性很高) |
No Bluetooth low energy activity (无BLE活动) | Flash operation will always succeed (Flash操作将始终成功) |
Comments | NOTHING