> and the SDRAM's DM signals are switched
Someone didn't understand "big endian" then?
> As a result, all byte writes to the RAM are swapped.
I'm surprised. Swapping the DQM signals swaps which LANE of the 16 bits gets written.
If you're seeing true byte-swaps then when you write a byte to the memory it must be putting the same data on both lanes.
> but I was hoping somebody might have a solution
You could program the ACR that covers the SDRAM to make the memory read-only and then trap and emulate every write. Might slow it down slightly...
There's an easier way. Just don't ever have the memory controller write bytes to the memory.
For accesses from the CPU that's simple. Just enable the cache in "Cacheable Copyback" mode. When you do that the CPU only ever reads full cache lines from the memory and (importantly for you) only ever WRITES full cache lines too.
If anything in the Linux startup or running code enables "Cache Inhibited" or "Cacheable Write-through" mode so some or all of the DRAM it will write the wrong bytes. So find all code in the whole distribution that writes to the CACR and ACRn registers and make sure it uses this mode. I would expect Linux should run "Copyback" and flush/purge DMA buffers when required.
Your next problem involves the DMA controllers. They read and write the memory directly, so any of them set up to perform byte writes are going to cause you problems. You may want to try to rewrite any problematic drivers to use programmed I/O for now.
If you have DMA peripherals you have to run and can't force not to perform byte writes, then put their buffers in your SRAM. If the FEC gives you problems, put its ring/control structures in SRAM.
Your main problem is probably going to be whatever bootstrap you are using. It may run with caches disabled and do byte writes. You should be able to find those, or work out how to enable the cache during the boot.
Tom
> We've tried manually re-soldering the connections on the PCB, but this has created other problems
Like what? I can't imagine what would go wrong with this. Find someone who is REALLY GOOD at this and let them try. It is amazing what some people can do with a soldering iron.
If you're getting timing errors with the pins swapped, then just slow down the memory bus for now. Running slower avoids a lot of problems.