Closed atandersson closed 3 years ago
I'm currently trying to implement this library to operate a CP on a Maxim Cortex-M4. Any tips would be appreciated.
Most of the platform dependent code is well abstracted, so you should be able to port libosdp to FreeRTOS with minimal effort. I have listed the things you need to do on the CP side, if you need to get the PD also working, similar methods exists for the PD too.
In src/osdp_cp.c
:
osdp_cp_setup()
with some ugly static stuffs that we always do in the embedded world.osdp_cp_setup()
) and then run the main state loop (osdp_cp_refresh()
) it whatever frequency you thing is reasonable (typically, one calls every 50ms is expected to meet various OSDP timing requirements).cp_send_command()
to send the OSDP packet over the ISR instead of calling pd->channel.send()
.cp_process_reply()
so that the UART data can be notified (since we can have ISRs now) instead of polling call to pd->channel.recv()
.In src/osdp_common.c
:
osdp_millis_now()
using some tick source provided by FreeRTOS so libosdp can get a sense of real world timings.Depending on the crypto library you are using, you can choose to use one of the files src/crypto/*.c
, or you'd have to create a new file there if you are using some other exotic library. And in that new file:
osdp_crypt_setup()
, osdp_encrypt()
, osdp_decrypt()
osdp_get_rand()
and osdp_crypt_teardown()
using some crypto library available in FreeRTOS.Hopefully, I've mentioned everything needed to accomplish this task do let me know if I missed anything. I did the above steps (and some more) when porting this library to Zephyr RTOS; you can have a look at that implementation if you need inspiration. Be informed that the zephyr implementation is not yet updated to libosdp's master.
Lastly, if you do get everything to work, don't forget to send a PR this way :-).
Cheers!
@patrick-compass confirmed (by email) that he is able to run LibOSDP on FreeRTOS after redefining some internal methods locally. Those symbols have been marked weak with commit: e3eb1fbd49c1bb189642c4230971232148e15bc8 (so it can be linked without any modification to the library).
Closing this issue.
@sidcha The repo has quite changed since the last comment. Could you please give some updated tips for the porting? Thank you
@laszlopataki, I reviewed the existing comment and found it to be valid, mostly. Where it didn't I have updated the comment instead of duplicating it. Can you please follow it and report issues you run into?
Would it be possible to port this library for using with FreeRTOS running on ARM MCU's? Some embedded solutions which are looking to start implementing OSDP today are running task schedulers like FreeRTOS on small ARM Cortex-M0/M3/M4 cores. I think it would be a nice feature to include an option/fork for building the library for these devices as well, especially the PD's which are most likely to run on cheaper MCU's.