Accessing External Memory Bus (EIM) on iMX6 via memory map

Hi

Unfortunately we do not have any sample code in regards to mmap and/or weim.
As the community post you reference states you can do what you do from the
command line with the devmem2 tool.

e.g. writting to connected SRAM:

root@colibri-imx6:~# devmem2 0x0a0001f8 w 0x01f855aa
/dev/mem opened.
Memory mapped at address 0x76f50000.
Read at address  0x0A0001F8 (0x76f501f8): 0x00000001
Write at address 0x0A0001F8 (0x76f501f8): 0x01F855AA, readback 0x01F855AA
root@colibri-imx6:~# devmem2 0x0a0001fc w 0x01fcaa55
/dev/mem opened.
Memory mapped at address 0x76fbc000.
Read at address  0x0A0001FC (0x76fbc1fc): 0x01F855AA
Write at address 0x0A0001FC (0x76fbc1fc): 0x01FCAA55, readback 0x01FCAA55

Reading this back:

root@colibri-imx6:~# devmem2 0x0a0001f8
/dev/mem opened.
Memory mapped at address 0x76f9f000.
Read at address  0x0A0001F8 (0x76f9f1f8): 0x01F855AA
root@colibri-imx6:~# devmem2 0x0a0001fc
/dev/mem opened.
Memory mapped at address 0x76fc2000.
Read at address  0x0A0001FC (0x76fc21fc): 0x01FCAA55

Using your ‘C’ program:

root@colibri-imx6:~# ./weim_mmap
/dev/mem opened.
Memory (0xa000000) mapped at address 0x76fec000.
Value at address 0x1F8 (0x76fec1f8): 0x1F855AA
Value at address 0x1FC (0x76fec1fc): 0x1FCAA55

One thing which can go wrong would be the address mapping to the pins.
One can have the byte address at the pins, for the 16 bit wide bus this would set the A0 pin to always be 0. Or one can have the word address at the pins, i.e shifting the byte address by 1 to the right.
Compare with ‘22.5.2 Bus Sizing Configuration’ in the i.MX6SDLRM reference manual.

The current configuration in the device tree is to shift the addresses, so when the address pins are set to 0 you get the byte0 and byte1, when the address is set to 1 you get byte2 and byte3 of your memory mapped device.

Note the fsl,weim-cs-timing property in the device-tree and its description in the device-tree bindings.

Max