RogerClark wrote: ↑Sun Feb 03, 2019 12:59 am
[Will the core's need to be updated ?
Since the application code will need to have its start address (of the vector table), at 0x800000
Or do you think that the cores may generate position independent code ?
( My guess is that the code is not guaranteed to be position independent)
The HID bootloader contains a ZIP file to patch your core, and this PR contains a new updated one, and @BennehBoy send a PR to integrate it into the STM Core:
https://github.com/stm32duino/Arduino_C ... 2/pull/415
Basically, this patch replaces the "board.txt", "platform.txt" to add the HID bootloader, includes the "usb_serial.cpp" with the DTR + magic word, and adds the linker scripts to match the bootloader memory organization.
It would be great to update your core, but maybe wait a little bit more until the HID bootloader is more stable?
I don't think the core will need to generate PIC, but having a different file for each bootloader is a pain. We could take @BennehBoy and @fpiSTM idea and perform
linker script preprocessing in the "platform.txt" file:
Code: Select all
# preprocess linker file
preprocld.name=preproc.ld
preprocld.filepath={build.path}/{preprocld.name}
preprocld.flags=-DLD_MAX_SIZE={upload.maximum_size} -DLD_MAX_DATA_SIZE={upload.maximum_data_size}
recipe.hooks.linking.prelink.1.pattern="{compiler.path}{compiler.c.cmd}" -x c -E -P {preprocld.flags} {compiler.c.flags} {build.info.flags} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "{build.variant.path}/{build.ldscript}" -o "{preprocld.filepath}"
The
linker script for the Bluepill can then become:
Code: Select all
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = LD_MAX_SIZE
It should be possible to define some new tags in the "board.txt" and "platform.txt" to accomodate for the different bootloader configurations: low/high memory and user sketch/bootloader size and generate a linker script on the fly after cpp preprocessing.
Anyway, the HID bootloader being in high-memory, the sketch base address is now compatible with the STLink, JLink, serial and OCD bootloaders, and this technique could well be applicable to the DFU bootloader too.