Skip to content

Commit ba2a31e

Browse files
committed
Add KL27 bootloader and microbit interface projects
Modify yamls to point to kl27 and microbit v2 board files Change KL27 interface flash size to 128KB and RAM to 32KB Adapt UART driver to LPUART peripheral and add clock drivers Change KL27 device specific header files based on NXP SDK Add HIC and board info to info.py
1 parent fdf82e5 commit ba2a31e

File tree

21 files changed

+4050
-2410
lines changed

21 files changed

+4050
-2410
lines changed

projects.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ module:
5050
- records/rtos/rtos-cm0.yaml
5151
- records/hic_hal/kl26z.yaml
5252
- records/usb/usb-bulk.yaml
53+
hic_kl27z: &module_hic_kl27z
54+
- records/rtos/rtos-cm0.yaml
55+
- records/hic_hal/kl27z.yaml
56+
- records/usb/usb-bulk.yaml
5357
hic_lpc11u35: &module_hic_lpc11u35
5458
- records/rtos/rtos-cm0.yaml
5559
- records/hic_hal/lpc11u35.yaml
@@ -82,6 +86,10 @@ projects:
8286
- *module_if
8387
- *module_hic_kl26z
8488
- records/family/all_family.yaml
89+
kl27z_bl:
90+
- *module_bl
91+
- records/hic_hal/kl27z.yaml
92+
- records/board/kl27z_bl.yaml
8593
k20dx_bl:
8694
- *module_bl
8795
- records/hic_hal/k20dx.yaml
@@ -154,6 +162,10 @@ projects:
154162
- *module_if
155163
- *module_hic_kl26z
156164
- records/board/microbit.yaml
165+
kl27z_microbit_if:
166+
- *module_if
167+
- *module_hic_kl27z
168+
- records/board/microbitv2.yaml
157169
kl26z_nina_b1_if:
158170
- *module_if
159171
- *module_hic_kl26z

records/board/kl27z_bl.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
common:
22
sources:
33
board:
4-
- source/board/kl26z_bl.c
4+
- source/board/kl27z_bl.c

records/board/microbitv2.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ common:
66
- USB_PROD_STR="BBC micro:bit CMSIS-DAP"
77
sources:
88
board:
9-
- source/board/microbit.c
10-
family:
11-
- source/family/nordic/nrf51822/target_16.c
12-
- source/family/nordic/target_reset_nrf51.c
9+
- source/board/microbitv2/microbitv2.c
10+
target:
11+
- source/family/nordic/nrf5x/target.c
12+
- source/family/nordic/target_reset_nrf52.c

records/hic_hal/kl27z.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
common:
22
target:
3-
- mkl26z128xxx4
3+
- mkl27z256xxx4
44
core:
55
- Cortex-M0+
66
macros:
7-
- INTERFACE_KL26Z
8-
- CPU_MKL26Z128VLH4
9-
- DAPLINK_HIC_ID=0x97969901 # DAPLINK_HIC_ID_KL26
7+
- INTERFACE_KL27Z
8+
- CPU_MKL27Z256VFM4
9+
- DAPLINK_HIC_ID=0x9796990B # DAPLINK_HIC_ID_KL27
1010
- FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT=0
1111
- FLASH_DRIVER_IS_FLASH_RESIDENT=1
1212
- DAPLINK_NO_ASSERT_FILENAMES
1313
- OS_CLOCK=48000000
1414
includes:
15-
- source/hic_hal/freescale/kl26z
16-
- source/hic_hal/freescale/kl26z/MKL26Z4
17-
- projectfiles/uvision/kl26z_bl/build
15+
- source/hic_hal/freescale/kl27z
16+
- source/hic_hal/freescale/kl27z/MKL27Z4
17+
- projectfiles/uvision/kl27z_bl/build
1818
sources:
1919
hic_hal:
2020
- source/hic_hal/freescale
21-
- source/hic_hal/freescale/kl26z
22-
- source/hic_hal/freescale/kl26z/MKL26Z4
23-
- source/hic_hal/freescale/kl26z/armcc
21+
- source/hic_hal/freescale/kl27z
22+
- source/hic_hal/freescale/kl27z/MKL27Z4
23+
- source/hic_hal/freescale/kl27z/armcc
2424
fsl_flash_driver:
2525
- source/hic_hal/freescale/iap
2626

2727
tool_specific:
2828
uvision:
2929
misc:
3030
ld_flags:
31-
- --predefine="-I..\..\..\source\hic_hal\freescale\kl26z"
31+
- --predefine="-I..\..\..\source\hic_hal\freescale\kl27z"
3232
make_armcc:
3333
misc:
3434
ld_flags:
35-
- --predefine="-Isource\hic_hal\freescale\kl26z"
35+
- --predefine="-Isource\hic_hal\freescale\kl27z"

source/board/kl27z_bl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @file kl26z_bl.c
3-
* @brief board ID and meta-data for the hardware interface circuit (HIC) based on the NXP KL26Z
2+
* @file kl27z_bl.c
3+
* @brief board ID and meta-data for the hardware interface circuit (HIC) based on the NXP KL27Z
44
*
55
* DAPLink Interface Firmware
66
* Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
@@ -27,7 +27,7 @@
2727

2828
// Warning - changing the interface start will break backwards compatibility
2929
COMPILER_ASSERT(DAPLINK_ROM_IF_START == KB(32));
30-
COMPILER_ASSERT(DAPLINK_ROM_IF_SIZE == KB(95));
30+
COMPILER_ASSERT(DAPLINK_ROM_IF_SIZE == (KB(128) - KB(32) - KB(1)));
3131

3232
/**
3333
* List of start and size for each size of flash sector
@@ -47,8 +47,8 @@ target_cfg_t target_device = {
4747
.flash_regions[0].start = DAPLINK_ROM_IF_START,
4848
.flash_regions[0].end = DAPLINK_ROM_IF_START + DAPLINK_ROM_IF_SIZE,
4949
.flash_regions[0].flags = kRegionIsDefault,
50-
.ram_regions[0].start = 0x1FFFF000,
51-
.ram_regions[0].end = 0x20003000,
50+
.ram_regions[0].start = 0x1FFFE000,
51+
.ram_regions[0].end = 0x20006000,
5252
};
5353

5454
//bootloader has no family

source/board/microbitv2/microbitv2.c

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file microbit.c
2+
* @file microbitv2.c
33
* @brief board ID for the BBC Microbit board
44
*
55
* DAPLink Interface Firmware
@@ -24,49 +24,14 @@
2424
#include "target_family.h"
2525
#include "target_board.h"
2626

27-
const char * const board_id_mb_1_3 = "9900";
28-
const char * const board_id_mb_1_5 = "9901";
27+
const char * const board_id_mb_2_0 = "9903";
2928

30-
typedef enum {
31-
BOARD_VERSION_1_3 = 0,
32-
BOARD_VERSION_1_5 = 1,
33-
} mb_version_t;
34-
35-
// Enables Board Type Pin, reads it and disables it
36-
// Depends on gpio_init() to have been executed already
37-
static uint8_t read_board_type_pin(void) {
38-
uint8_t pin_state = 0;
39-
// GPIO mode, Pull enable, pull down, input
40-
PIN_BOARD_TYPE_PORT->PCR[PIN_BOARD_TYPE_BIT] = PORT_PCR_MUX(1) | PORT_PCR_PE(1) | PORT_PCR_PS(0);
41-
PIN_BOARD_TYPE_GPIO->PDDR &= ~PIN_BOARD_TYPE;
42-
// Wait to stabilise, based on gpio.c busy_wait(), at -O2 10000 iterations delay ~850us
43-
for (volatile uint32_t i = 10000; i > 0; i--);
44-
// Read pin
45-
pin_state = (PIN_BOARD_TYPE_GPIO->PDIR & PIN_BOARD_TYPE);
46-
// Revert and disable
47-
PIN_BOARD_TYPE_PORT->PCR[PIN_BOARD_TYPE_BIT] = PORT_PCR_MUX(0) | PORT_PCR_PE(0);
48-
return pin_state;
49-
}
50-
51-
static void set_board_id(mb_version_t board_version) {
52-
switch (board_version) {
53-
case BOARD_VERSION_1_3:
54-
target_device.rt_board_id = board_id_mb_1_3;
55-
break;
56-
case BOARD_VERSION_1_5:
57-
target_device.rt_board_id = board_id_mb_1_5;
58-
break;
59-
default:
60-
target_device.rt_board_id = board_id_mb_1_5;
61-
break;
62-
}
63-
}
29+
extern target_cfg_t target_device_nrf52_64;
6430

6531
// Called in main_task() to init before USB and files are configured
6632
static void prerun_board_config(void) {
67-
// With only two boards the digital pin read maps directly to the type
68-
mb_version_t board_version = (mb_version_t)read_board_type_pin();
69-
set_board_id(board_version);
33+
target_device = target_device_nrf52_64;
34+
target_device.rt_board_id = board_id_mb_2_0;
7035
}
7136

7237
// USB HID override function return 1 if the activity is trivial or response is null
@@ -80,9 +45,9 @@ uint8_t usbd_hid_no_activity(uint8_t *buf)
8045

8146
const board_info_t g_board_info = {
8247
.info_version = kBoardInfoVersion,
83-
.family_id = kNordic_Nrf51_FamilyID,
48+
.family_id = kNordic_Nrf52_FamilyID,
8449
.daplink_url_name = "MICROBITHTM",
85-
.daplink_drive_name = "MICROBIT ",
50+
.daplink_drive_name = "MICROBIT",
8651
.daplink_target_url = "https://microbit.org/device/?id=@B&v=@V",
8752
.prerun_board_config = prerun_board_config,
8853
.target_cfg = &target_device,

source/hic_hal/device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#if defined (INTERFACE_K20D5) \
2626
|| defined (INTERFACE_K26F) \
2727
|| defined (INTERFACE_KL26Z) \
28+
|| defined (INTERFACE_KL27Z) \
2829
|| defined (INTERFACE_LPC55XX)
2930
#include "fsl_device_registers.h"
3031
#elif defined (INTERFACE_LPC11U35)
Lines changed: 45 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file IO_Config.h
3-
* @brief
3+
* @brief
44
*
55
* DAPLink Interface Firmware
66
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
@@ -30,98 +30,83 @@
3030
#ifndef __IO_CONFIG_H__
3131
#define __IO_CONFIG_H__
3232

33-
#include "MKL26Z4.h"
33+
#include "MKL27Z4.h"
3434
#include "compiler.h"
3535
#include "daplink.h"
3636

37-
// This GPIO configuration is only valid for the KL26 HIC
38-
COMPILER_ASSERT(DAPLINK_HIC_ID == DAPLINK_HIC_ID_KL26);
37+
// This GPIO configuration is only valid for the KL27 HIC
38+
COMPILER_ASSERT(DAPLINK_HIC_ID == DAPLINK_HIC_ID_KL27Z);
3939

4040

4141
// Debug Port I/O Pins
4242

43-
// SWCLK Pin PTC5(C5)
43+
// SWCLK Pin PTC6
4444
#define PIN_SWCLK_PORT PORTC
4545
#define PIN_SWCLK_GPIO PTC
46-
#define PIN_SWCLK_BIT (5)
46+
#define PIN_SWCLK_BIT (6)
4747
#define PIN_SWCLK (1<<PIN_SWCLK_BIT)
4848

49-
// SWDIO Pin PTC6(C6)
49+
// SWDIO Pin PTC5
5050
#define PIN_SWDIO_PORT PORTC
5151
#define PIN_SWDIO_GPIO PTC
52-
#define PIN_SWDIO_BIT (6)
52+
#define PIN_SWDIO_BIT (5)
5353
#define PIN_SWDIO (1<<PIN_SWDIO_BIT)
5454

55-
// nRESET Pin PTC8(C8)
56-
#define PIN_nRESET_PORT PORTC
57-
#define PIN_nRESET_GPIO PTC
58-
#define PIN_nRESET_BIT (8)
55+
// nRESET Pin PTA20
56+
#define PIN_nRESET_PORT PORTA
57+
#define PIN_nRESET_GPIO PTA
58+
#define PIN_nRESET_BIT (20)
5959
#define PIN_nRESET (1<<PIN_nRESET_BIT)
6060

61-
// PWR_REG_EN PTD2 - Not connected
62-
#define PIN_POWER_EN_PORT PORTD
63-
#define PIN_POWER_EN_GPIO PTD
64-
#define PIN_POWER_EN_BIT (2)
65-
#define PIN_POWER_EN (1<<PIN_POWER_EN_BIT)
66-
67-
// VTRG_FAULT_B PTD3 - Not connected
68-
#define PIN_VTRG_FAULT_B_PORT PORTD
69-
#define PIN_VTRG_FAULT_B_GPIO PTD
70-
#define PIN_VTRG_FAULT_B_BIT (7)
71-
#define PIN_VTRG_FAULT_B_EN (1<<PIN_VTRG_FAULT_B_BIT)
72-
7361
// Debug Unit LEDs
7462

75-
// HID_LED PTD4
76-
#define PIN_HID_LED_PORT PORTD
77-
#define PIN_HID_LED_GPIO PTD
78-
#define PIN_HID_LED_BIT (4)
63+
// HID_LED PTB0
64+
#define PIN_HID_LED_PORT PORTB
65+
#define PIN_HID_LED_GPIO PTB
66+
#define PIN_HID_LED_BIT (0)
7967
#define PIN_HID_LED (1<<PIN_HID_LED_BIT)
68+
#define PIN_HID_LED_MUX_ALT (1)
8069

81-
// MSC_LED PTD5
82-
#define PIN_MSC_LED_PORT PORTD
83-
#define PIN_MSC_LED_GPIO PTD
84-
#define PIN_MSC_LED_BIT (4)
70+
// MSC_LED PTB0
71+
#define PIN_MSC_LED_PORT PORTB
72+
#define PIN_MSC_LED_GPIO PTB
73+
#define PIN_MSC_LED_BIT (0)
8574
#define PIN_MSC_LED (1<<PIN_MSC_LED_BIT)
75+
#define PIN_MSC_LED_MUX_ALT (1)
8676

87-
// CDC_LED PTD6
88-
#define PIN_CDC_LED_PORT PORTD
89-
#define PIN_CDC_LED_GPIO PTD
90-
#define PIN_CDC_LED_BIT (4)
77+
// CDC_LED PTB0
78+
#define PIN_CDC_LED_PORT PORTB
79+
#define PIN_CDC_LED_GPIO PTB
80+
#define PIN_CDC_LED_BIT (0)
9181
#define PIN_CDC_LED (1<<PIN_CDC_LED_BIT)
82+
#define PIN_CDC_LED_MUX_ALT (1)
9283

93-
// SW RESET BUTTON PTB1
94-
#define PIN_SW_RESET_PORT PORTB
95-
#define PIN_SW_RESET_GPIO PTB
96-
#define PIN_SW_RESET_BIT (1)
97-
#define PIN_SW_RESET (1<<PIN_SW_RESET_BIT)
98-
99-
// BOARD TYPE
100-
#define PIN_BOARD_TYPE_PORT PORTB
101-
#define PIN_BOARD_TYPE_GPIO PTB
102-
#define PIN_BOARD_TYPE_BIT (0)
103-
#define PIN_BOARD_TYPE (1<<PIN_BOARD_TYPE_BIT)
104-
105-
// Connected LED Not available
84+
// Reset pins
10685

107-
// Target Running LED Not available
86+
// SW RESET BUTTON PTD4
87+
#define PIN_SW_RESET_PORT PORTD
88+
#define PIN_SW_RESET_GPIO PTD
89+
#define PIN_SW_RESET_BIT (4)
90+
#define PIN_SW_RESET (1<<PIN_SW_RESET_BIT)
91+
#define SW_RESET_PRESSED (0)
92+
#define SW_RESET_NOT_PRESSED (1)
10893

10994
// UART
110-
#define UART_PORT PORTC
95+
#define UART_PORT PORTA
11196
#define UART_NUM (1)
112-
// RX PTC3
113-
#define PIN_UART_RX_GPIO PTC
114-
#define PIN_UART_RX_BIT (3)
97+
// RX PTA18
98+
#define PIN_UART_RX_GPIO PTA
99+
#define PIN_UART_RX_BIT (18)
115100
#define PIN_UART_RX (1<<PIN_UART_RX_BIT)
116101
#define PIN_UART_RX_MUX_ALT (3)
117-
// TX PTC4
118-
#define PIN_UART_TX_GPIO PTC
119-
#define PIN_UART_TX_BIT (4)
102+
// TX PTA19
103+
#define PIN_UART_TX_GPIO PTA
104+
#define PIN_UART_TX_BIT (19)
120105
#define PIN_UART_TX (1<<PIN_UART_TX_BIT)
121106
#define PIN_UART_TX_MUX_ALT (3)
122107

123-
#define UART UART1
124-
#define UART_RX_TX_IRQn UART1_IRQn
125-
#define UART_RX_TX_IRQHandler UART1_IRQHandler
108+
#define UART LPUART1
109+
#define UART_RX_TX_IRQn LPUART1_IRQn
110+
#define UART_RX_TX_IRQHandler LPUART1_IRQHandler
126111

127112
#endif

0 commit comments

Comments
 (0)