mehrdadh commented on code in PR #13885:
URL: https://github.com/apache/tvm/pull/13885#discussion_r1093811741


##########
tests/micro/zephyr/test_zephyr.py:
##########
@@ -608,5 +608,41 @@ def 
test_schedule_build_with_cmsis_dependency(workspace_dir, board, microtvm_deb
     assert "CMSIS-NN/Include" in cmake_content
 
 
[email protected]_micro
+def test_debugging_enabled(workspace_dir):
+    """Test debugging enabled for LED.
+    We used a physical board(nucleo_l4r5zi) instead of QEMU since
+    LED config is not available on QEMU.

Review Comment:
   done



##########
apps/microtvm/zephyr/template_project/src/mlperftiny/platform.cc:
##########
@@ -162,3 +173,62 @@ int8_t QuantizeFloatToInt8(float value, float scale, int 
zero_point) {
   }
   return (int8_t)(result);
 }
+
+// UART interrupt callback.
+void uart_irq_cb(const struct device* dev, void* user_data) {
+  while (uart_irq_update(dev) && uart_irq_is_pending(dev)) {
+    struct ring_buf* rbuf = (struct ring_buf*)user_data;
+    if (uart_irq_rx_ready(dev) != 0) {
+      for (;;) {
+        // Read a small chunk of data from the UART.
+        int bytes_read = uart_fifo_read(dev, uart_data, sizeof(uart_data));
+        if (bytes_read < 0) {
+          TVMPlatformAbort((tvm_crt_error_t)(0xbeef1));
+        } else if (bytes_read == 0) {
+          break;
+        }
+        // Write it into the ring buffer.
+        int bytes_written = ring_buf_put(rbuf, uart_data, bytes_read);
+        if (bytes_read != bytes_written) {
+          TVMPlatformAbort((tvm_crt_error_t)(0xbeef2));
+        }
+      }
+    }
+  }
+}
+
+// Initialize the UART receiver.
+void uart_rx_init(struct ring_buf* rbuf, const struct device* dev) {

Review Comment:
   removed both



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -658,13 +668,30 @@ def generate_project(self, model_library_format_path, 
standalone_crt_dir, projec
             API_SERVER_DIR / "crt_config" / "crt_config.h", crt_config_dir / 
"crt_config.h"
         )
 
-        # Populate src/
+        # Populate src and include
         src_dir = project_dir / "src"
-        if project_type != "host_driven" or self._is_fvp(zephyr_board, 
use_fvp):
-            shutil.copytree(API_SERVER_DIR / "src" / project_type, src_dir)
-        else:
-            src_dir.mkdir()
-            shutil.copy2(API_SERVER_DIR / "src" / project_type / "main.c", 
src_dir)
+        src_dir.mkdir()
+        include_dir = project_dir / "include" / "tvm"
+        include_dir.mkdir(parents=True)
+        for file in os.listdir(API_SERVER_DIR / "src" / project_type):

Review Comment:
   done



##########
apps/microtvm/zephyr/template_project/src/mlperftiny/platform.cc:
##########
@@ -49,14 +55,8 @@ int8_t g_quant_zero = OUT_QUANT_ZERO;
 #endif
 size_t g_output_data_len = output_data_len;
 
-// WORKSPACE_SIZE is defined in python
-static uint8_t g_aot_memory[WORKSPACE_SIZE];
-tvm_workspace_t app_workspace;
-
-size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes, 
const char* fmt,
-                                va_list args) {
-  return vsnprintk(out_buf, out_buf_size_bytes, fmt, args);
-}
+static const struct device* g_microtvm_uart;
+static uint8_t uart_data[8];

Review Comment:
   that's no longer used, so I removed `uart_data`



##########
apps/microtvm/zephyr/template_project/src/mlperftiny/platform.h:
##########
@@ -59,4 +62,28 @@ void TVMInfer(void* input_ptr);
  */
 int8_t QuantizeFloatToInt8(float value, float scale, int zero_point);
 
-#endif /* APPS_MICROTVM_ZEPHYR_TEMPLATE_PROJECT_SRC_MLPERFTINY_TVMRUNTIME_H_ */
+/*!
+ * \brief Read Uart Rx buffer.
+ * \param data Pointer to read data.
+ * \param data_size_bytes Read request size in bytes.
+ *
+ * \return Number of data read in bytes.
+ */
+char TVMPlatformUartRxRead();

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to