Skip to content

Commit

Permalink
[microTVM] Add Nucleo stm32l4r5zi board to zephyr (apache#8386)
Browse files Browse the repository at this point in the history
* add stm32l4r5zi_nucleo

* add parameter for test qemu

* file type check

* fix test

* change order

* revert
  • Loading branch information
mehrdadh authored and ylc committed Jan 13, 2022
1 parent 8fb4c5e commit a06207a
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 5 deletions.
31 changes: 31 additions & 0 deletions apps/microtvm/zephyr/aot_demo/boards/nucleo_l4r5zi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# This file is specific to the STM32L4R5ZI Nucleo board.

# For intrinsics used by generated optimized operators.
CONFIG_CMSIS_DSP=y

# For AOT runtime which requires lots of function call.
CONFIG_MAIN_STACK_SIZE=3000

# For random number generation.
CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y

# For debugging.
CONFIG_LED=y
6 changes: 6 additions & 0 deletions apps/microtvm/zephyr/aot_demo/src/zephyr_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,11 @@ uint32_t TVMPlatformWriteSerial(const char* data, uint32_t size) {
void TVMPlatformUARTInit() {
// Claim console device.
g_microtvm_uart = device_get_binding(DT_LABEL(DT_CHOSEN(zephyr_console)));
const struct uart_config config = {.baudrate = 115200,
.parity = UART_CFG_PARITY_NONE,
.stop_bits = UART_CFG_STOP_BITS_1,
.data_bits = UART_CFG_DATA_BITS_8,
.flow_ctrl = UART_CFG_FLOW_CTRL_NONE};
uart_configure(g_microtvm_uart, &config);
uart_rx_init(&uart_rx_rbuf, g_microtvm_uart);
}
31 changes: 31 additions & 0 deletions apps/microtvm/zephyr/host_driven/boards/nucleo_l4r5zi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# This file is specific to the STM32L4R5ZI Nucleo board.

# For intrinsics used by generated optimized operators.
CONFIG_CMSIS_DSP=y

# For operations that stack allocates a large float array.
CONFIG_MAIN_STACK_SIZE=1536

# For random number generation.
CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y

# For debugging.
CONFIG_LED=y
1 change: 1 addition & 0 deletions python/tvm/micro/contrib/zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ def _get_nrf_device_args(self):

# kwargs passed to usb.core.find to find attached boards for the openocd flash runner.
BOARD_USB_FIND_KW = {
"nucleo_l4r5zi": {"idVendor": 0x0483, "idProduct": 0x374B},
"nucleo_f746zg": {"idVendor": 0x0483, "idProduct": 0x374B},
"stm32f746g_disco": {"idVendor": 0x0483, "idProduct": 0x374B},
}
Expand Down
5 changes: 3 additions & 2 deletions python/tvm/target/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,10 @@ def intel_graphics(model="unknown", options=None):

MICRO_SUPPORTED_MODELS = {
"host": [],
"stm32f746xx": ["-mcpu=cortex-m7", "-march=armv7e-m"],
"nrf5340dk": ["-mcpu=cortex-m33"],
"mps2_an521": ["-mcpu=cortex-m33"],
"nrf5340dk": ["-mcpu=cortex-m33"],
"stm32f746xx": ["-mcpu=cortex-m7", "-march=armv7e-m"],
"stm32l4r5zi": ["-mcpu=cortex-m4"],
}


Expand Down
2 changes: 2 additions & 0 deletions tests/lint/check_file_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"apps/microtvm/zephyr/host_driven/boards/nucleo_f746zg.conf",
"apps/microtvm/zephyr/host_driven/boards/stm32f746g_disco.conf",
"apps/microtvm/zephyr/host_driven/boards/mps2_an521.conf",
"apps/microtvm/zephyr/host_driven/boards/nucleo_l4r5zi.conf",
"apps/microtvm/zephyr/host_driven/qemu-hack",
"apps/microtvm/zephyr/aot_demo/prj.conf",
"apps/microtvm/zephyr/aot_demo/boards/qemu_x86.conf",
Expand All @@ -153,6 +154,7 @@
"apps/microtvm/zephyr/aot_demo/boards/nucleo_f746zg.conf",
"apps/microtvm/zephyr/aot_demo/boards/stm32f746g_disco.conf",
"apps/microtvm/zephyr/aot_demo/boards/mps2_an521.conf",
"apps/microtvm/zephyr/aot_demo/boards/nucleo_l4r5zi.conf",
"apps/microtvm/zephyr/aot_demo/qemu-hack",
# microTVM Virtual Machines
"apps/microtvm/reference-vm/zephyr/Vagrantfile",
Expand Down
7 changes: 4 additions & 3 deletions tests/micro/zephyr/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
"host": ("host", "qemu_x86"),
"host_riscv32": ("host", "qemu_riscv32"),
"host_riscv64": ("host", "qemu_riscv64"),
"stm32f746xx_nucleo": ("stm32f746xx", "nucleo_f746zg"),
"stm32f746xx_disco": ("stm32f746xx", "stm32f746g_disco"),
"nrf5340dk": ("nrf5340dk", "nrf5340dk_nrf5340_cpuapp"),
"mps2_an521": ("mps2_an521", "mps2_an521-qemu"),
"nrf5340dk": ("nrf5340dk", "nrf5340dk_nrf5340_cpuapp"),
"stm32f746xx_disco": ("stm32f746xx", "stm32f746g_disco"),
"stm32f746xx_nucleo": ("stm32f746xx", "nucleo_f746zg"),
"stm32l4r5zi_nucleo": ("stm32l4r5zi", "nucleo_l4r5zi"),
}


Expand Down

0 comments on commit a06207a

Please sign in to comment.