Skip to content

Commit

Permalink
kl27z_hic: Add ROM bootloader configuration to GCC builds.
Browse files Browse the repository at this point in the history
As done with the armcc builds, this only enables USB in the ROM
bootloader, so that any random traffic in the I2C/SPI/UART pins
doesn't accidentally trigger the bootloader.
  • Loading branch information
microbit-carlos authored and mbrossard committed May 18, 2022
1 parent f5c5896 commit 29ce012
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
11 changes: 10 additions & 1 deletion source/hic_hal/freescale/kinetis.ld
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : DAPLINK_STACK_SIZE;
/* Specify the memory areas */
MEMORY
{
m_interrupts (RX) : ORIGIN = DAPLINK_ROM_APP_START, LENGTH = 0x400
#if defined(DAPLINK_BL)
m_interrupts (RX) : ORIGIN = DAPLINK_ROM_APP_START, LENGTH = 0x3C0
m_bootloader_config (RX) : ORIGIN = DAPLINK_ROM_APP_START + 0x3C0, LENGTH = 0x40
m_flash_config (RX) : ORIGIN = DAPLINK_ROM_APP_START + 0x400, LENGTH = 0x10
m_text (RX) : ORIGIN = DAPLINK_ROM_APP_START + 0x410, LENGTH = DAPLINK_ROM_APP_SIZE - 0x410
#else
m_interrupts (RX) : ORIGIN = DAPLINK_ROM_APP_START, LENGTH = 0x400
m_text (RX) : ORIGIN = DAPLINK_ROM_APP_START + 0x400, LENGTH = DAPLINK_ROM_APP_SIZE - 0x400
#endif
m_cfgrom (RW) : ORIGIN = DAPLINK_ROM_CONFIG_USER_START, LENGTH = DAPLINK_ROM_CONFIG_USER_SIZE
Expand All @@ -59,6 +61,13 @@ SECTIONS
} > m_interrupts

#if defined(DAPLINK_BL)
.bootloader_config :
{
. = ALIGN(4);
KEEP(*(.BootloaderConfig)) /* Bootloader Configuration Area (BCA) */
. = ALIGN(4);
} > m_bootloader_config

.flash_config :
{
. = ALIGN(4);
Expand Down
25 changes: 24 additions & 1 deletion source/hic_hal/freescale/kl27z/gcc/startup_MKL27Z4.S
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,30 @@ __isr_vector:
.size __isr_vector, . - __isr_vector

#if defined(DAPLINK_BL)
/* TODO: Bootloader Configuration Area (BCA) used by Kinetis ROM Bootloader */
/* Bootloader Configuration Area (BCA) used by Kinetis ROM Bootloader */
.section .BootloaderConfig, "a"
.long 0x6766636B /* 0x00 Magic number to verify bootloader configuration is valid. Must be set to 'kcfg'. */
.long 0xFFFFFFFF /* 0x04 Reserved */
.long 0xFFFFFFFF /* 0x08 Reserved */
.long 0xFFFFFFFF /* 0x0C Reserved */
.byte 0x10 /* 0x10 Bitfield of peripherals to enable. bit 0 LPUART, bit 1 I2C, bit 2 SPI, bit 4 USB. 0x10 = USB only */
.byte 0xFF /* 0x11 i2cSlaveAddress */
.byte 0xFF, 0xFF /* 0x12 peripheralDetectionTimeout */
.byte 0xFF, 0xFF /* 0x14 usbVid */
.byte 0xFF, 0xFF /* 0x16 usbPid */
.long 0xFFFFFFFF /* 0x18 usbStringsPointer */
.byte 0xFF /* 0x1C clockFlags */
.byte 0xFF /* 0x1D clockDivider */
.byte 0xFF /* 0x1E bootFlags */
.byte 0xFF /* 0x1F pad byte */
.long 0xFFFFFFFF /* 0x20 Reserved */
.long 0xFFFFFFFF /* 0x24 Reserved */
.long 0xFFFFFFFF /* 0x28 Reserved */
.long 0xFFFFFFFF /* 0x2C Reserved */
.long 0xFFFFFFFF /* 0x30 Reserved */
.long 0xFFFFFFFF /* 0x34 Reserved */
.long 0xFFFFFFFF /* 0x38 Reserved */
.long 0xFFFFFFFF /* 0x3C Reserved */

/* Flash Configuration */
.section .FlashConfig, "a"
Expand Down

0 comments on commit 29ce012

Please sign in to comment.