Skip to content

Commit 3fcfbbd

Browse files
author
Jamie Smith
authored
Fix some issues with building on K64F, add K64F upload methods (ARMmbed#267)
* Fix some issues with building on K64F, add K64F upload methods * Add Mbed upload method * Fix pin validate test * Also install json5 * Fix incorrect COMPONENT_SD config
1 parent acfd341 commit 3fcfbbd

File tree

13 files changed

+86
-43
lines changed

13 files changed

+86
-43
lines changed

.github/workflows/basic_checks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ jobs:
193193
name: validate pins
194194
run: |
195195
set -x
196+
python3 -m pip install json5
196197
git config --global --add safe.directory "$GITHUB_WORKSPACE"
197198
git diff --name-only --diff-filter=d origin/${GITHUB_BASE_REF} \
198199
| ( grep '.*[\\|\/]PinNames.h$' || true ) \

connectivity/drivers/802.15.4_RF/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ endmacro(create_mbed_802_15_4_target)
1818

1919

2020
if("Freescale" IN_LIST MBED_TARGET_LABELS)
21-
create_mbed_802_15_4_target()
2221
add_subdirectory(TARGET_Freescale)
2322
elseif("Silicon_Labs" IN_LIST MBED_TARGET_LABELS)
24-
create_mbed_802_15_4_target()
2523
add_subdirectory(TARGET_Silicon_Labs)
2624
endif()
2725

connectivity/drivers/802.15.4_RF/TARGET_Freescale/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
if("KW41Z" IN_LIST MBED_TARGET_LABELS)
5+
create_mbed_802_15_4_target()
56
add_subdirectory(TARGET_KW41Z)
67
endif()

connectivity/drivers/802.15.4_RF/TARGET_Silicon_Labs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
if("SL_RAIL" IN_LIST MBED_TARGET_LABELS)
5+
create_mbed_802_15_4_target()
56
add_subdirectory(TARGET_SL_RAIL)
67
endif()

hal/tests/pinvalidate/pinvalidate.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"""
1818

1919
import argparse
20-
import json
20+
import json5
2121
import pathlib
2222
import hashlib
2323
import re
@@ -26,6 +26,12 @@
2626
from itertools import chain
2727
from enum import Enum
2828

29+
# Load targets data from JSON
30+
mbed_os_root = pathlib.Path(__file__).absolute().parents[3]
31+
with (
32+
mbed_os_root.joinpath("targets", "targets.json5")
33+
).open() as targets_json_file:
34+
target_data = json5.load(targets_json_file)
2935

3036
class ReturnCode(Enum):
3137
"""Return codes."""
@@ -76,11 +82,6 @@ def find_target_by_path(target_path):
7682
print("WARNING: MBED TARGET LIST marker invalid or not found in file " + target_path)
7783
print("Target could not be determined. Only the generic test suite will run. You can manually specify additional suites.")
7884

79-
with (
80-
mbed_os_root.joinpath("targets", "targets.json")
81-
).open() as targets_json_file:
82-
target_data = json.load(targets_json_file)
83-
8485
# find target in targets.json
8586
for target in target_data:
8687
if "public" in target_data[target]:
@@ -97,7 +98,6 @@ def find_target_by_path(target_path):
9798

9899
def find_target_by_name(target_name=""):
99100
"""Find a target by name."""
100-
mbed_os_root = pathlib.Path(__file__).absolute().parents[3]
101101

102102
targets = dict()
103103

@@ -133,15 +133,10 @@ def find_target_by_name(target_name=""):
133133

134134
def check_markers(test_mode=False):
135135
"""Validate markers in PinNames.h files"""
136-
mbed_os_root = pathlib.Path(__file__).absolute().parents[3]
136+
137137

138138
errors = []
139139

140-
with (
141-
mbed_os_root.joinpath("targets", "targets.json")
142-
).open() as targets_json_file:
143-
targets_json = json.load(targets_json_file)
144-
145140
if test_mode:
146141
search_dir = pathlib.Path(__file__).parent.joinpath('test_files').absolute()
147142
else:
@@ -187,8 +182,6 @@ def check_markers(test_mode=False):
187182

188183
def check_duplicate_pinnames_files(test_mode=False):
189184
"""Check for duplicate PinNames.h files"""
190-
mbed_os_root = pathlib.Path(__file__).absolute().parents[3]
191-
192185
errors = []
193186

194187
file_hash_dict = dict()
@@ -220,8 +213,6 @@ def check_duplicate_pinnames_files(test_mode=False):
220213

221214
def check_duplicate_markers(test_mode=False):
222215
"""Check target markers in PinNames.h files for duplicates."""
223-
mbed_os_root = pathlib.Path(__file__).absolute().parents[3]
224-
225216
errors = []
226217

227218
markers = dict()
@@ -262,13 +253,6 @@ def check_duplicate_markers(test_mode=False):
262253

263254
def target_has_form_factor(target_name, form_factor):
264255
"""Check if the target has the Arduino form factor."""
265-
mbed_os_root = pathlib.Path(__file__).absolute().parents[3]
266-
267-
with (
268-
mbed_os_root.joinpath("targets", "targets.json")
269-
).open() as targets_json_file:
270-
target_data = json.load(targets_json_file)
271-
272256
if target_name in target_data:
273257
if "supported_form_factors" in target_data[target_name]:
274258
form_factors = target_data[target_name]["supported_form_factors"]

storage/blockdevice/COMPONENT_SD/mbed_lib.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@
5757
"SPI_CS": "PTD4"
5858
},
5959
"K64F": {
60-
"SPI_CS": "SPI_CS",
61-
"SPI_MOSI": "SPI_MOSI",
62-
"SPI_MISO": "SPI_MISO",
63-
"SPI_CLK": "SPI_SCK"
60+
"SPI_CS": "PTE4",
61+
"SPI_MOSI": "PTE3",
62+
"SPI_MISO": "PTE1",
63+
"SPI_CLK": "PTE2"
6464
},
6565
"K66F": {
6666
"SPI_MOSI": "PTE3",

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PinNames.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,6 @@ typedef enum {
262262
#define BUTTON2 SW3
263263

264264

265-
// SPI Pins for SD card.
266-
// Note: They are different from the Arduino Uno SPI pins
267-
// (ARDUINO_UNO_SPI_xxx) for general purpose uses.
268-
// By default, Mbed OS maps those alias to Arduino Uno pins, but
269-
// for backward compatibility we map them to the SD card SPI.
270-
#define SPI_MOSI PTE3
271-
#define SPI_MISO PTE1
272-
#define SPI_SCK PTE2
273-
#define SPI_CS PTE4
274-
275-
276265
#ifdef __cplusplus
277266
}
278267
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/cmsis_nvic.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,21 @@ extern uint32_t __VECTOR_RAM[];
4242
#define NVIC_NUM_VECTORS (16 + 86) // CORE + MCU Peripherals
4343
#define NVIC_RAM_VECTOR_ADDRESS (__VECTOR_RAM) // Vectors positioned at start of RAM
4444

45+
#ifndef MBED_RAM_SIZE
46+
#define MBED_RAM_SIZE 0x30000
47+
#endif
48+
49+
#ifndef MBED_RAM_START
50+
#define MBED_RAM_START 0x20000000
51+
#endif
52+
53+
#ifndef MBED_RAM1_SIZE
54+
#define MBED_RAM1_SIZE 0x10000
55+
#endif
56+
57+
#ifndef MBED_RAM1_START
58+
#define MBED_RAM1_START 0x1FFF0000
59+
#endif
60+
61+
4562
#endif

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/spi_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ static void spi_buffer_set(spi_t *obj, const void *tx, uint32_t tx_length, void
361361
bool spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx, size_t rx_length, uint8_t bit_width, uint32_t handler, uint32_t event, DMAUsage hint)
362362
{
363363
if (spi_active(obj)) {
364-
return;
364+
return false;
365365
}
366366

367367
/* check corner case */

targets/upload_method_cfg/K64F.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Mbed OS upload method configuration file for target K64F.
2+
# To change any of these parameters from their default values, set them in your build script between where you
3+
# include app.cmake and where you add mbed os as a subdirectory.
4+
#
5+
# Notes:
6+
# 1. PyOCD did not actually work in my testing as of Apr 2024, though this device is supposed to be supported
7+
# 2. Be sure to update the DAPLink firmware on the board via these instructions: https://os.mbed.com/blog/entry/DAPLink-bootloader-update/
8+
9+
# General config parameters
10+
# -------------------------------------------------------------
11+
set(UPLOAD_METHOD_DEFAULT MBED)
12+
13+
# Config options for MBED
14+
# -------------------------------------------------------------
15+
16+
set(MBED_UPLOAD_ENABLED TRUE)
17+
set(MBED_RESET_BAUDRATE 115200)
18+
19+
# Config options for PYOCD
20+
# -------------------------------------------------------------
21+
set(PYOCD_UPLOAD_ENABLED TRUE)
22+
set(PYOCD_TARGET_NAME k64f)
23+
set(PYOCD_CLOCK_SPEED 4000k)
24+
25+
# Config options for OPENOCD
26+
# -------------------------------------------------------------
27+
28+
set(OPENOCD_UPLOAD_ENABLED TRUE)
29+
set(OPENOCD_CHIP_CONFIG_COMMANDS
30+
-f ${CMAKE_CURRENT_LIST_DIR}/openocd_cfgs/mk64f.cfg)
31+
32+
# Config options for LINKSERVER
33+
# -------------------------------------------------------------
34+
set(LINKSERVER_UPLOAD_ENABLED TRUE)
35+
set(LINKSERVER_DEVICE MK64FN1M0xxx12:FRDM-K64F)

targets/upload_method_cfg/LPC1768.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# To change any of these parameters from their default values, set them in your build script between where you
33
# include app.cmake and where you add mbed os as a subdirectory.
44

5+
# Notes:
6+
# 1. LPC1768 is supposed to be supported by LinkServer, and I am able to get through flashing it, but it errors out at the end.
7+
58
# General config parameters
69
# -------------------------------------------------------------
710
set(UPLOAD_METHOD_DEFAULT MBED)
@@ -33,3 +36,8 @@ set(MBED_RESET_BAUDRATE 115200)
3336
set(OPENOCD_UPLOAD_ENABLED TRUE)
3437
set(OPENOCD_CHIP_CONFIG_COMMANDS
3538
-f ${CMAKE_CURRENT_LIST_DIR}/openocd_cfgs/lpc1768.cfg)
39+
40+
# Config options for LINKSERVER
41+
# -------------------------------------------------------------
42+
set(LINKSERVER_UPLOAD_ENABLED TRUE)
43+
set(LINKSERVER_DEVICE LPC1768)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# OpenOCD config file for Kinetis K64F chips using DAPLink
2+
3+
source [find interface/cmsis-dap.cfg]
4+
5+
transport select swd
6+
7+
source [find target/k60.cfg]
8+
9+
reset_config srst_only

tools/cmake/upload_methods/UploadMethodPYOCD.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set(UPLOAD_PYOCD_FOUND ${HAVE_PYOCD})
1919
set(PYOCD_PROBE_UID "" CACHE STRING "Probe UID to pass to pyOCD commands. You can get the UIDs from `python -m pyocd list`. Set to empty to detect any probe.")
2020

2121
### Function to generate upload target
22-
set(PYOCD_PROBE_ARGS "")
22+
set(PYOCD_PROBE_ARGS "" CACHE INTERNAL "" FORCE)
2323
if(NOT "${PYOCD_PROBE_UID}" STREQUAL "")
2424
set(PYOCD_PROBE_ARGS --probe ${PYOCD_PROBE_UID} CACHE INTERNAL "" FORCE)
2525
endif()

0 commit comments

Comments
 (0)