The boot loader code itself is written to the board like any other code using the provided interface (J link in your case). Boot loaders are commmonly used to allow updating application code later without using the board specific programming interface. So a user might install an update using a normal PC with a serial interface.
For PCs without serial interfaces, an USB to serial converter can be used.
A serial boot loader is one that uses a serial interface for communication. Once activated (via hardware event like a button press and/or checking an input pin upon every reset), it will wait for commands send on the serial line and allows writing to the flash memory.
A possible implementation for a button activation may be:
- A flag in memory cleared upon power on indicating that the loader should be executed.
- Upon reset (software or hardware like power on), the flag is checked. If set, the boot loader is started. Otherwise the application code is started.
- Using an interrupt handler for the button to set the flag and perform a software reset.
- The boot loader code checking the flag is located at the reset address.
- The application code is located at a fixed address behind the boot loader.
A simpler implementation may use an input pin with a jumper that must be set to activate the programming mode upon reset.
When you want to write a boot loader you should know before what it should do (e.g. allow updating of application code and perform additional tasks). Once you know that you should define some kind of protocol to use (the commands and syntax). A comfortable boot loader might provide a simple interactive interface like a command shell.