Close

DMA FTW!

A project log for Orthrus

SD card secure RAID USB storage

nick-sayerNick Sayer 04/29/2017 at 04:470 Comments

After a lot of fussing around this evening, I finally got DMA based AES working.

It turns out we have to use 3 DMA channels to get it working - one each to transfer the key and nonce into AES and the third to transfer the pre-ciphertext out. The first two can run simultaneously and there's tricky logic in the ISR (it's common for both of those channels) to figure out when both transfers are finished before starting AES. The third channel triggers on AES completion, and its ISR checks for completion, increments the counter and kicks off the two inward channels.

The net result is a 20% speed boost. We're now up to 220 KB/sec. And that tops out this hardware rev. We'll have to wait for the next one to come back to see how much (if anything) we get from USART in SPI master mode. And that will likely mark the completion of the project.

EDIT: If that wasn't enough, I followed it up with automatic AES triggering. That gets rid of the first two ISRs, which gives us another 5 kB/sec. Now AES automatically starts when the key and data are filled in, and then channel 2 is triggered when it's done. The ISR for channel 2 just checks for completion, increments the nonce counter and triggers channels 0 and 1.

Discussions