stm32 programming stm32 or beaglebone
The ST-Link is basically just a STM32F103 which will interface to the PC on one side and the MCU under development on the other side and download new code to it.

I haven't seen a firmware or source code available to build your own ST-Link, so I guess it's still closed. But considering that a Nucleo Board contains a ST-Link and costs only 10 bucks, it's maybe not worth the trouble to build one on your own. There are some tries to get a linux driver for a ST-Link here.

The internal bootloader on the STM32F4 is quite flexible and allows different interfaces to be used. There are specifications for each of the protocols available:


AN3155 - USART 
AN3156 - USB DFU
AN4221 - I2C
AN4286 - SPI


There are different ways to get into the bootloader, depending on which chip you use and other boundaries.

One of the easier ways to get there is to pull the BOOT0 pin high and reset the device. Then it boots into the bootloader and the before mentioned protocols are available.

For windows there is a GUI and command line tool available under the name STSW-MCU005 Flash loader demonstrator. That thing comes with source code, so probably you are able to port it to Linux and make it run on your beaglebone. That way it might be possible to skip fully understanding all the protocol details (though that never hurts).

The JTAG protocol is (as far as I know) not freely available, so implementing your own JTAG flasher would require you getting a copy of the IEEE 1149.1 and going on from there. Another option is to get a copy of the ARM Debug Interface Architecture Specification (available for free upon registration with ARM). I haven't looked into it in detail, but it seems to describe the debug capabilities of the ARM cores in great detail. So that might be a better starting point than the IEEE standard.

I don't know if ST has some extensions on the JTAG/SWD protocol, some vendors do this.

That said your best bet is probably the internal bootloader if you want to get results faster. As long as you don't program your controller in a way so that it is no longer accessible.