As a solution I've started to rebuild some of the data aquisition boards, and designing a new CAN based communication protocol. The goal is to get rid of most of the old Modbus based boards. There will be still one board acting as a gateway from CAN to Modbus.
The key requirements for the CAN protocol are:
To fulfill the first two requirements, I've set up a makefile framework which supports using the same source code in multiple projects. This way I'm able to include the same protocol code and data definitions into all projects, compile and deploy the binaries over CAN to all boards, just by typing "make". No need for extensive runtime configuration of the data transfers. Everything is kept consistent at compile time.
The makefile framework is organized this way:
Throw the mandatory ("pjhdr.mk" and "pj.mk") and optional makefile includes together into the project specific Makefile. Use the makefile of one of the projects or the template from "pj-template" as a starting point. The template schema is expandable for more libraries, common code, debuggers, other microcontroller families and so on.
I've integrated some great OSS into this framework:
There is some modification of ChibiOS required to get it working together with OpenBLT:
The latter two were well documented by OpenBLT, the first one was rather dastardly: OpenBLT writes a checksum right after the last vector table entry, same address for every derivative, but the ChibiOS vector table varies in size according to the used derivative. So on my first tries to get it up and running, OpenBLT patched its checksum into code, which made it fail. The simple and after discovering the issue obvious fix is to patch ChibiOS to always create the largest derivatives vector table.
One additional item for updating the firmware over CAN is required: some kind of a CAN adapter for the PC. I've used this one: UConnect for XE164. This is a simple demo kit by Infineon promoting their XE16x controllers. Afaik this particular kit isn't available any more, I've used it simply because it was there at the right time. There comes a demo firmware with this kit, the "horch" application, this is a simple CAN to UART over USB gateway. I've modified this firmware and the SerialBoot application from openBLT to work together.
The project isn't finished yet at the time of this writing. It contains the makefile framework itself, the STM32 standard peripheral library, ChibiOS, OpenBLT. Included are three projects using my simple and stupid homebus CAN protocol as a shared code base:
Find my makefile framework and the related code here: The source tarball
The source code for the UConnect board: can-gw.zip
Look here: The STM32 files for my other STM32 related pages.