Correct way of modifying HAL for custom STM32F2xx PCB


We’ve developed a board based quite closely on the Particle Electron (using the same micro).
We’ve used a couple of micro pins that weren’t run out to headers on the Electron and hence haven’t been assigned a high level pin name (e.g D5)
I’ve read through the HAL files in the firmware, namely:


I think I’ve got a reasonable idea what’s going on, however I’m unsure what the ‘by the book’ way is to deal with this.

Should we create a custom PLATFORM_ID for our product and compile locally using modified pinmap.hal files?
Or is it simpler to create a file within our application that patches in the required HAL code for the new pins?

This might be a good example of which files are touched for adding a new pin. Not everything is required, but more than the two files you mentioned are typically modified.

I think it would be simpler to patch in the functionality for a few pins in your user app, depending on what that functionality is exactly of course. If you don’t have to duplicate lots of system firmware it makes sense.