From 3247a96588ad9a37e30d03ac12bb01cf3c15080d Mon Sep 17 00:00:00 2001 From: Martin Kojtal <0xc0170@gmail.com> Date: Sun, 31 Dec 2017 09:47:25 +0100 Subject: [PATCH 1/5] renesas: os tick only for rtos As this is os tick implementation for rtos, it should not be compilied if rtos not present (mbed 2) --- targets/TARGET_RENESAS/TARGET_RZ_A1H/device/os_tick_ostm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/targets/TARGET_RENESAS/TARGET_RZ_A1H/device/os_tick_ostm.c b/targets/TARGET_RENESAS/TARGET_RZ_A1H/device/os_tick_ostm.c index 7926421c0d5..bebd3e114f2 100644 --- a/targets/TARGET_RENESAS/TARGET_RZ_A1H/device/os_tick_ostm.c +++ b/targets/TARGET_RENESAS/TARGET_RZ_A1H/device/os_tick_ostm.c @@ -22,6 +22,8 @@ * limitations under the License. */ +#ifdef MBED_CONF_RTOS_PRESENT + #include "os_tick.h" #include "irq_ctrl.h" @@ -185,3 +187,6 @@ uint32_t OS_Tick_GetCount (void) { uint32_t OS_Tick_GetOverflow (void) { return (IRQ_GetPending(OSTM_IRQn)); } + +#endif + From 038324a7e525e41a917ab349740c98f689ffbb83 Mon Sep 17 00:00:00 2001 From: Martin Kojtal <0xc0170@gmail.com> Date: Sun, 31 Dec 2017 10:38:39 +0100 Subject: [PATCH 2/5] Travis: add RZ_A1H target Travis: dsp only for cortex-m --- .travis.yml | 2 ++ tools/build_travis.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/.travis.yml b/.travis.yml index a03c3af6922..15296cb3f16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -188,3 +188,5 @@ matrix: env: NAME=mbed2-ATMEL - <<: *mbed-2 env: NAME=mbed2-NUVOTON + - <<: *mbed-2 + env: NAME=mbed2-RENESAS diff --git a/tools/build_travis.py b/tools/build_travis.py index 432ca638da0..325a68d7283 100644 --- a/tools/build_travis.py +++ b/tools/build_travis.py @@ -168,6 +168,14 @@ { "target": "NUMAKER_PFM_M453", "toolchains": "GCC_ARM", "libs": ["dsp", "usb"] }, { "target": "NUMAKER_PFM_M487", "toolchains": "GCC_ARM", "libs": ["dsp", "usb"] }, ) + }, + + + { + "RENESAS": + ( + { "target": "RZ_A1H", "toolchains": "GCC_ARM" }, + ) } ] @@ -326,6 +334,17 @@ } } ) + }, + { + "RENESAS": + ( + { + "target": "RZ_A1H", + "toolchains": "GCC_ARM", + "tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_16"], + } + }, + ) } ] From e07b3c7ac6487a88223898486a44844819377b7b Mon Sep 17 00:00:00 2001 From: Martin Kojtal <0xc0170@gmail.com> Date: Mon, 1 Jan 2018 21:13:33 +0100 Subject: [PATCH 3/5] tools: cmsis and hal are build together Build api used to build cmsis separately (how mbed 2 is being build). This is currently not how cmsis is being defined. As there target dependencies in some cases, we should include paths from targets when building cmsis --- tools/build_api.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/tools/build_api.py b/tools/build_api.py index 5d9d613b813..1ed66530816 100644 --- a/tools/build_api.py +++ b/tools/build_api.py @@ -999,19 +999,6 @@ def build_mbed_libs(target, toolchain_name, verbose=False, config.add_config_files([MBED_CONFIG_FILE]) toolchain.set_config_data(toolchain.config.get_config_data()) - # CMSIS - toolchain.info("Building library %s (%s, %s)" % - ('CMSIS', target.name, toolchain_name)) - cmsis_src = MBED_CMSIS_PATH - resources = toolchain.scan_resources(cmsis_src) - - toolchain.copy_files(resources.headers, build_target) - toolchain.copy_files(resources.linker_script, build_toolchain) - toolchain.copy_files(resources.bin_files, build_toolchain) - - objects = toolchain.compile_sources(resources, tmp_path) - toolchain.copy_files(objects, build_toolchain) - # mbed toolchain.info("Building library %s (%s, %s)" % ('MBED', target.name, toolchain_name)) @@ -1027,9 +1014,12 @@ def build_mbed_libs(target, toolchain_name, verbose=False, toolchain.copy_files(resources.headers, dest) library_incdirs.append(dest) - # Target specific sources - hal_src = MBED_TARGETS_PATH - hal_implementation = toolchain.scan_resources(hal_src) + cmsis_implementation = toolchain.scan_resources(MBED_CMSIS_PATH) + toolchain.copy_files(cmsis_implementation.headers, build_target) + toolchain.copy_files(cmsis_implementation.linker_script, build_toolchain) + toolchain.copy_files(cmsis_implementation.bin_files, build_toolchain) + + hal_implementation = toolchain.scan_resources(MBED_TARGETS_PATH) toolchain.copy_files(hal_implementation.headers + hal_implementation.hex_files + hal_implementation.libraries + @@ -1038,8 +1028,8 @@ def build_mbed_libs(target, toolchain_name, verbose=False, toolchain.copy_files(hal_implementation.linker_script, build_toolchain) toolchain.copy_files(hal_implementation.bin_files, build_toolchain) incdirs = toolchain.scan_resources(build_target).inc_dirs - objects = toolchain.compile_sources(hal_implementation, - library_incdirs + incdirs) + objects = toolchain.compile_sources(cmsis_implementation + hal_implementation, + library_incdirs + incdirs + [tmp_path]) toolchain.copy_files(objects, build_toolchain) # Common Sources From fed5dd11702c46fa1a3312f4838c3ef61b765cf1 Mon Sep 17 00:00:00 2001 From: Martin Kojtal <0xc0170@gmail.com> Date: Tue, 2 Jan 2018 10:18:26 +0000 Subject: [PATCH 4/5] VK RZ A1H: fix errors from the latest cmsis updates Use mbed critical section --- .../TARGET_VK_RZ_A1H/device/VKRZA1H.h | 4 +- .../TARGET_VK_RZ_A1H/serial_api.c | 102 ++++-------------- .../TARGET_VK_RZ_A1H/us_ticker.c | 13 +-- 3 files changed, 26 insertions(+), 93 deletions(-) diff --git a/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/device/VKRZA1H.h b/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/device/VKRZA1H.h index 644e9882540..0a79f4c8e83 100644 --- a/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/device/VKRZA1H.h +++ b/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/device/VKRZA1H.h @@ -626,9 +626,9 @@ typedef enum IRQn #define __NVIC_PRIO_BITS 5 /*!< Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ -#include +#include "core_ca.h" #include "system_VKRZA1H.h" - +#include "iodefine.h" /******************************************************************************/ /* Device Specific Peripheral Section */ diff --git a/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/serial_api.c b/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/serial_api.c index 3982a77a9bb..f9a89359fdc 100644 --- a/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/serial_api.c +++ b/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/serial_api.c @@ -23,6 +23,7 @@ #include "cmsis.h" #include "pinmap.h" #include "gpio_api.h" +#include "mbed_critical.h" #include "scif_iodefine.h" #include "cpg_iodefine.h" @@ -570,21 +571,14 @@ static void serial_flow_irq_set(serial_t *obj, uint32_t enable) { int serial_getc(serial_t *obj) { uint16_t err_read; int data; - int was_masked; -#if defined ( __ICCARM__ ) - was_masked = __disable_irq_iar(); -#else - was_masked = __disable_irq(); -#endif /* __ICCARM__ */ + core_util_critical_section_enter(); if (obj->uart->SCFSR & 0x93) { err_read = obj->uart->SCFSR; obj->uart->SCFSR = (err_read & ~0x93); } obj->uart->SCSCR |= 0x0040; // Set RIE - if (!was_masked) { - __enable_irq(); - } + core_util_critical_section_exit(); if (obj->uart->SCLSR & 0x0001) { obj->uart->SCLSR = 0u; // ORER clear @@ -593,16 +587,12 @@ int serial_getc(serial_t *obj) { while (!serial_readable(obj)); data = obj->uart->SCFRDR & 0xff; -#if defined ( __ICCARM__ ) - was_masked = __disable_irq_iar(); -#else - was_masked = __disable_irq(); -#endif /* __ICCARM__ */ + core_util_critical_section_enter(); + err_read = obj->uart->SCFSR; obj->uart->SCFSR = (err_read & 0xfffD); // Clear RDF - if (!was_masked) { - __enable_irq(); - } + + core_util_critical_section_exit(); if (err_read & 0x80) { data = -1; //err @@ -612,29 +602,16 @@ int serial_getc(serial_t *obj) { void serial_putc(serial_t *obj, int c) { uint16_t dummy_read; - int was_masked; -#if defined ( __ICCARM__ ) - was_masked = __disable_irq_iar(); -#else - was_masked = __disable_irq(); -#endif /* __ICCARM__ */ + core_util_critical_section_enter(); obj->uart->SCSCR |= 0x0080; // Set TIE - if (!was_masked) { - __enable_irq(); - } + core_util_critical_section_exit(); while (!serial_writable(obj)); obj->uart->SCFTDR = c; -#if defined ( __ICCARM__ ) - was_masked = __disable_irq_iar(); -#else - was_masked = __disable_irq(); -#endif /* __ICCARM__ */ + core_util_critical_section_enter(); dummy_read = obj->uart->SCFSR; obj->uart->SCFSR = (dummy_read & 0xff9f); // Clear TEND/TDFE - if (!was_masked) { - __enable_irq(); - } + core_util_critical_section_exit(); uart_data[obj->index].count++; } @@ -647,20 +624,11 @@ int serial_writable(serial_t *obj) { } void serial_clear(serial_t *obj) { - int was_masked; -#if defined ( __ICCARM__ ) - was_masked = __disable_irq_iar(); -#else - was_masked = __disable_irq(); -#endif /* __ICCARM__ */ - + core_util_critical_section_enter(); obj->uart->SCFCR |= 0x06; // TFRST = 1, RFRST = 1 obj->uart->SCFCR &= ~0x06; // TFRST = 0, RFRST = 0 obj->uart->SCFSR &= ~0x0093u; // ER, BRK, RDF, DR = 0 - - if (!was_masked) { - __enable_irq(); - } + core_util_critical_section_exit(); } void serial_pinout_tx(PinName tx) { @@ -668,62 +636,34 @@ void serial_pinout_tx(PinName tx) { } void serial_break_set(serial_t *obj) { - int was_masked; -#if defined ( __ICCARM__ ) - was_masked = __disable_irq_iar(); -#else - was_masked = __disable_irq(); -#endif /* __ICCARM__ */ + core_util_critical_section_enter(); // TxD Output(L) obj->uart->SCSPTR &= ~0x0001u; // SPB2DT = 0 obj->uart->SCSCR &= ~0x0020u; // TE = 0 (Output disable) - if (!was_masked) { - __enable_irq(); - } + core_util_critical_section_exit(); } void serial_break_clear(serial_t *obj) { - int was_masked; -#if defined ( __ICCARM__ ) - was_masked = __disable_irq_iar(); -#else - was_masked = __disable_irq(); -#endif /* __ICCARM__ */ + core_util_critical_section_enter(); obj->uart->SCSCR |= 0x0020u; // TE = 1 (Output enable) obj->uart->SCSPTR |= 0x0001u; // SPB2DT = 1 - if (!was_masked) { - __enable_irq(); - } + core_util_critical_section_exit(); } void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow) { // determine the UART to use - int was_masked; - serial_flow_irq_set(obj, 0); if (type == FlowControlRTSCTS) { -#if defined ( __ICCARM__ ) - was_masked = __disable_irq_iar(); -#else - was_masked = __disable_irq(); -#endif /* __ICCARM__ */ + core_util_critical_section_enter(); obj->uart->SCFCR = 0x0008u; // CTS/RTS enable - if (!was_masked) { - __enable_irq(); - } + core_util_critical_section_exit(); pinmap_pinout(rxflow, PinMap_UART_RTS); pinmap_pinout(txflow, PinMap_UART_CTS); } else { -#if defined ( __ICCARM__ ) - was_masked = __disable_irq_iar(); -#else - was_masked = __disable_irq(); -#endif /* __ICCARM__ */ + core_util_critical_section_enter(); obj->uart->SCFCR = 0x0000u; // CTS/RTS diable - if (!was_masked) { - __enable_irq(); - } + core_util_critical_section_exit(); } } diff --git a/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/us_ticker.c b/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/us_ticker.c index 6bcaea41d6c..e2c15edbde9 100644 --- a/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/us_ticker.c +++ b/targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/us_ticker.c @@ -20,6 +20,7 @@ #include "RZ_A1_Init.h" #include "VKRZA1H.h" +#include "mbed_critical.h" #define US_TICKER_TIMER_IRQn (OSTMI1TINT_IRQn) #define CPG_STBCR5_BIT_MSTP50 (0x01u) /* OSTM1 */ @@ -83,22 +84,14 @@ static uint64_t ticker_read_counter64(void) { uint32_t us_ticker_read() { uint64_t cnt_val64; uint64_t us_val64; - int check_irq_masked; -#if defined ( __ICCARM__) - check_irq_masked = __disable_irq_iar(); -#else - check_irq_masked = __disable_irq(); -#endif /* __ICCARM__ */ + core_util_critical_section_enter(); cnt_val64 = ticker_read_counter64(); us_val64 = (cnt_val64 / count_clock); ticker_us_last64 = us_val64; - if (!check_irq_masked) { - __enable_irq(); - } - + core_util_critical_section_exit(); /* clock to us */ return (uint32_t)us_val64; } From a8fc394942d7be85c71792fb31ff6adcae76a672 Mon Sep 17 00:00:00 2001 From: Martin Kojtal <0xc0170@gmail.com> Date: Tue, 2 Jan 2018 11:30:35 +0000 Subject: [PATCH 5/5] VK RZ A1H: remove target from mbed 2 release As it does not share the codebase with RZ A1H, it needs to be disabled until bring it up to date with the latest changes to cmsis. There are changes regarding caches, mmu and others --- targets/targets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/targets.json b/targets/targets.json index a9f032c925c..dfd17df2b52 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -2411,7 +2411,7 @@ "device_has": ["ANALOGIN", "CAN", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SPI", "SPISLAVE", "STDIO_MESSAGES"], "features": ["LWIP"], "default_lib": "std", - "release_versions": ["2"] + "release_versions": [] }, "MAXWSNENV": { "inherits": ["Target"],