In freescale released iMX25 Linux BSP, when we access the WEIM register as followed, we will get "Unhandled fault".
/unit_tests/memtool 0xb8002060 1
That is because theLinux kernel hasn't mapped the IO space for WEIM registers.
We can check the kernel file "arch\arm\mach-mx25\mm.c"
static struct map_desc mxc_io_desc[] __initdata = {
{
.virtual = MX25_AVIC_BASE_ADDR_VIRT,
.pfn = __phys_to_pfn(MX25_AVIC_BASE_ADDR),
.length = MX25_AVIC_SIZE,
.type = MT_DEVICE_NONSHARED
}, {
.virtual = MX25_AIPS1_BASE_ADDR_VIRT,
.pfn = __phys_to_pfn(MX25_AIPS1_BASE_ADDR),
.length = MX25_AIPS1_SIZE,
.type = MT_DEVICE_NONSHARED
}, {
.virtual = MX25_AIPS2_BASE_ADDR_VIRT,
.pfn = __phys_to_pfn(MX25_AIPS2_BASE_ADDR),
.length = MX25_AIPS2_SIZE,
.type = MT_DEVICE_NONSHARED
},
};
The BSP mapped three regions of IO registers, AVIC, AIPS1 and AIPS2, each region is 1MB, WEIM registers are not included in them.
When the memtool try to access an unmapped address, it will get the "Unhandled fault" as you see.
To access the WEIM registers with memtool, you can added the followed codes:
In kernel file "arch\arm\plat-mxc\include\mach\mx25.h",
added the followed codes:
#define MX25_EMI_BASE_ADDR 0xb8000000
#define MX25_EMI_BASE_ADDR_VIRT 0xfc600000
#define MX25_EMI_SIZE SZ_1M
Modify
#define MX25_IO_ADDRESS(x) ( \
IMX_IO_ADDRESS(x, MX25_AIPS1) ?: \
IMX_IO_ADDRESS(x, MX25_AIPS2) ?: \
IMX_IO_ADDRESS(x, MX25_AVIC))
To
#define MX25_IO_ADDRESS(x) ( \
IMX_IO_ADDRESS(x, MX25_AIPS1) ?: \
IMX_IO_ADDRESS(x, MX25_AIPS2) ?: \
IMX_IO_ADDRESS(x, MX25_AVIC) ?: \
IMX_IO_ADDRESS(x, MX25_EMI))
In kernel file "arch\arm\mach-mx25\mm.c", update the struct mxc_io_desc[] to followed:
static struct map_desc mxc_io_desc[] __initdata = {
{
.virtual = MX25_AVIC_BASE_ADDR_VIRT,
.pfn = __phys_to_pfn(MX25_AVIC_BASE_ADDR),
.length = MX25_AVIC_SIZE,
.type = MT_DEVICE_NONSHARED
}, {
.virtual = MX25_AIPS1_BASE_ADDR_VIRT,
.pfn = __phys_to_pfn(MX25_AIPS1_BASE_ADDR),
.length = MX25_AIPS1_SIZE,
.type = MT_DEVICE_NONSHARED
}, {
.virtual = MX25_AIPS2_BASE_ADDR_VIRT,
.pfn = __phys_to_pfn(MX25_AIPS2_BASE_ADDR),
.length = MX25_AIPS2_SIZE,
.type = MT_DEVICE_NONSHARED
}, {
.virtual = MX25_EMI_BASE_ADDR_VIRT,
.pfn = __phys_to_pfn(MX25_EMI_BASE_ADDR),
.length = MX25_EMI_SIZE,
.type = MT_DEVICE_NONSHARED
},
};