用某ARM芯片做硬件逻辑解压缩,从其开源的Uboot里取出解压缩代码,拿到LiteOS里面使用。

先从Flash读取压缩文件到内存, 申请一块足够大的目标Buffer, 将两块内存交给解压硬件逻辑,有低概率解失败; 

  。。。

在读取flash上的压缩数据到内存后,将这段存放压缩数据的内存进行clean cache操作,没有复现此问题。

原因应该是解压缩逻辑没有使用Cache里的内容, 直接访问内存,访问的数据可能跟flash上的不一致。
清Cache操作会使cache写入内存,确保数据是一致的。invalidate Cache会丢弃cache里的数据。

以下摘自《ARM Cortex-A Series Programmer’s Guide》

8.8 Invalidating and cleaning cache memory
Cleaning and invalidation can be required when the contents of external
memory have been changed and you want to remove stale data from the cache. It
can also be required after MMU related activity such as changing access
permissions, cache policies, or virtual to physical address mappings.
The word flush is often used in descriptions of clean and invalidate
operations. ARM generally
uses only the terms clean and invalidate.
• Invalidation of a cache or cache line means to clear it of data. This is
done by clearing the valid bit of one or more cache lines. The cache must
always be invalidated after reset as its contents will be undefined. If the
cache contains dirty data, it is generally incorrect to invalidate it. Any
updated data in the cache from writes to write-back cacheable regions would be
lost by simple invalidation.
• Cleaning a cache or cache line means writing the contents of dirty cache
lines out to main memory and clearing the dirty bit(s) in the cache line. This
makes the contents of the cache line and main memory coherent with each other.
This is only applicable for data caches in which a write-back policy is used.
Cache invalidate, and cache clean operations can be performed by cache set, or
way, or by virtual address.

技术
下载桌面版
GitHub
Gitee
SourceForge
百度网盘(提取码:draw)
云服务器优惠
华为云优惠券
腾讯云优惠券
阿里云优惠券
Vultr优惠券
站点信息
问题反馈
邮箱:[email protected]
吐槽一下
QQ群:766591547
关注微信