Armadilloフォーラム

[Armadillo-IoT G3]データキャッシュの有効化について

ueoka

2022年9月9日 18時18分

お世話になっております。

u-bootのソースコード(uboot_2016.07-at23)をダウンロードし、
/uboot_2016.07-at23/READMEを確認すると、
1083行目-1090行目に以下の説明文がありました。

(READMEの説明文)
Don't enable the "icache" and "dcache" commands (configuration option CONFIG_CMD_CACHE) unless you know what you (and your U-Boot users) are doing. Data cache cannot be enabled on systems like the 8xx or 8260 (where accesses to the IMMR region must be uncached), and it cannot be disabled on all other systems where we (mis-) use the data cache to hold an initial stack and some data.

「/uboot_2016.07-at23/configs/x1_defconfig」を確認すると、「CONFIG_CMD_CACHE=y」となっていました。
これは、u-bootでキャッシュを有効にしているという意味で良いでしょうか?

その場合、「SPLからu-bootに切り替わる時」、「u-bootからLinux kernelに切り替わる時」に、
キャッシュの内容は破棄されてから切り替わるのでしょうか?

(現時点で何か問題になっている訳ではありません。)

以上、宜しくお願いいたします。

コメント

at_mizo

2022年9月13日 13時04分

溝渕です。

> 「/uboot_2016.07-at23/configs/x1_defconfig」を確認すると、「CONFIG_CMD_CACHE=y」となっていました。
> これは、u-bootでキャッシュを有効にしているという意味で良いでしょうか?

いえ。違います。u-bootのcacheコマンドを有効にしています。

> その場合、「SPLからu-bootに切り替わる時」、「u-bootからLinux kernelに切り替わる時」に、
> キャッシュの内容は破棄されてから切り替わるのでしょうか?

少なくともLinuxを起動するときにはcacheは破棄されます。以下のcleanup_before_linux()の中でcacheが破棄されます。

arch/arm/lib/bootm.c:
static void announce_and_cleanup(int fake)
{
 :snip
	cleanup_before_linux();
}

ueoka

2022年9月13日 16時44分

溝渕様

お世話になっております。
本件について、ご回答いただきありがとうございました。

at_mizo

2022年9月13日 17時02分

溝渕です。

ちなみにですが、U-Bootでは起動時にI/D cacheはonになります。該当箇所は次の通りです。

warch/arm/cpu/armv7/start.S:
ENTRY(cpu_init_cp15)
 :snip
#ifdef CONFIG_SYS_ICACHE_OFF
	bic	r0, r0, #0x00001000	@ clear bit 12 (I) I-cache
#else
	orr	r0, r0, #0x00001000	@ set bit 12 (I) I-cache
#endif
arch/arm/imx-common/cache.c:
#ifndef CONFIG_SYS_DCACHE_OFF
void enable_caches(void)
{
 :snip
	/* Enable D-cache. I-cache is already enabled in start.S */
	dcache_enable();