We have been working on the product on both K22 and K20 controller. We are developing an static library (archive) for K22. Now other than controller family, functionality and every other feature are identical for K22 and K20 product.
So the query is,
It depends in 'no small part' on whether you are coming from K22 or K22--A. The 'A' part is 'much closer' to the K20, BUT virtually ALL different members of Kinetis M4-devices still contain variations from such basic things as clock-setup and vector-table, to deeper issues of peripheral-instantiation-configuration such as the FIFO-depth on the SPI ports. To get one binary that runs 'either processor' will require code that checks WHICH it is actually on, and make at LEAST the appropriate initial setup differences.
both the K22 and K20 are ARM Cortex-M4 devices. As long as you are only using Cortex-M4 features, the code is compatible. I assume you are using the K22 with floating point unit? In that case be aware that the K20 does not have this, and mixing libraries will be problematic if FPU is used. The other thing is: if you are using device specific peripherals (UART/SPI/etc): they are similar, but not the same.
I hope this helps,