# Dual Core ## Setup Environment Goal: Ensure a simple program can run on the dual core mcu successfully. - Setup cubeIDE for dual core https://www.youtube.com/watch?v=jI1k6p-fduE - Debugging for dual core - https://www.youtube.com/watch?v=k3mXhPZSasw (Official tutorial) - Download program without dubugging on STM32CubeIDE (Need to download ST-LINK Utility or STM32CubeProgrammer) - https://www.youtube.com/watch?v=BdNq7bfXtjs - [Discovery kit with STM32H747XI MCU - User manual](https://www.st.com/resource/en/user_manual/dm00504240-discovery-kit-with-stm32h747xi-mcu-stmicroelectronics.pdf) - Development environment choices - STM32cubeIDE (including STM32cubeMX) - STM32cubeMX + Keil MDK - Communicate between CM4 and CM7 https://community.st.com/s/article/stm32h7-dual-core-how-to-communicate-between-cm4-cm7 https://www.st.com/resource/en/reference_manual/rm0399-stm32h745755-and-stm32h747757-advanced-armbased-32bit-mcus-stmicroelectronics.pdf (p.554) (HSEM register map: p.566) ## Issues - HSEM: (HS) - survey FreeRTOS - Ensure tasks order - between different CPU - Resorce Sharing (YF) - 64KB SRAM are accessible for CM4 and CM7 - Scheduling - Pipeline - split two cores for each op - grouping layers - High resolution solution (CC) - frame diff - port model on F767 (one core) (CC and YC) - mobilevit with mbedOS - mobilevit with stm32cubeIDE - cubeAI - pipeline - profiler - 找出model中所有cut vertices - ![](https://i.imgur.com/DGy3osl.png) - profile程序 - 用cut vertex把model分成兩部分 - 大core拿前半段,小core拿後半段 - 跑一遍看各自花多少時間 - report 所有cut vertices情形的latency數據 - profile一遍找最好的分配方式 - 最好的定義lat_c0最接近lat_c1 - parallelize op 內 計算 - 拆tile分給兩個core - statically - compile time 決定,定義在model file的op參數裡 - dynamically - 用特殊的方式算出比例 - 什麼方式要再想 - 或用producer-consumer架構,讓core自己去搶tile計算 - 需要之道拆成多小的tile才不會對compiler優化有影響 - 特殊方式分配計算 - 什麼方式要再想 - 必須考量到compiler好不好優化 Reference: https://www.st.com/resource/en/application_note/an5617-stm32h745755-and-stm32h747757-lines-interprocessor-communications-stmicroelectronics.pdf ## Run a model - Bring tflm to dual core https://mirzafahad.github.io/2020-06-26-tflite-stm32-part3/ https://www.youtube.com/watch?v=gDFWCxrJruQ - Replace tflm with tinyTS - Schedule a model on CM4 and CM7