{"id":15643066,"url":"https://github.com/nihui/ncnn_on_esp32","last_synced_at":"2025-04-19T11:57:40.899Z","repository":{"id":139969511,"uuid":"392008034","full_name":"nihui/ncnn_on_esp32","owner":"nihui","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-14T07:02:06.000Z","size":89,"stargazers_count":75,"open_issues_count":4,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-12T17:51:56.192Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nihui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-02T15:50:08.000Z","updated_at":"2025-02-27T13:31:22.000Z","dependencies_parsed_at":"2024-04-14T08:24:42.491Z","dependency_job_id":"22e49390-663a-4570-a1ef-679930d3cf6c","html_url":"https://github.com/nihui/ncnn_on_esp32","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihui%2Fncnn_on_esp32","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihui%2Fncnn_on_esp32/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihui%2Fncnn_on_esp32/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihui%2Fncnn_on_esp32/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nihui","download_url":"https://codeload.github.com/nihui/ncnn_on_esp32/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246155984,"owners_count":20732355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T11:58:47.328Z","updated_at":"2025-03-30T21:31:48.420Z","avatar_url":"https://github.com/nihui.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ncnn on esp32\n\n### 1. setup esp-idf\n\nsee https://github.com/espressif/esp-idf\n\n### 2. build ncnn library for esp32\n\n```shell\ngit clone https://github.com/Tencent/ncnn.git\n\nmkdir build-esp32\ncd build-esp32\ncmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/esp32c6.toolchain.cmake ..\nmake -j4\nmake install\n```\n\n### 3. build ncnn esp32 mnist sample\n\nmodify `ncnn_DIR` in `CMakeLists.txt` to your ncnn installation\n```cmake\nset(ncnn_DIR \"/home/nihui/dev/ncnn/build-esp32/install/lib/cmake/ncnn\")\n```\n\nenable sgemm convolution for esp32c6 / esp32s3 with larger ram, edit `main/main.cpp`\n\n```cpp\n// but esp32c3 has lower memory\nnet.opt.use_sgemm_convolution = true;\n```\n\nbuild project with idf.py\n```shell\nidf.py set-target esp32c6\nidf.py menuconfig\n\nidf.py build\n```\n\n### 4. flash to device and monitor serial port\n\n```shell\nidf.py flash\n```\n\n```shell\ntio /dev/ttyACM0\n```\nor\n```shell\ntio /dev/ttyUSB0\n```\n\n### esp32c3\n\n```\nESP-ROM:esp32c3-api1-20210207\nBuild:Feb  7 2021\nrst:0xc (RTC_SW_CPU_RST),boot:0xc (SPI_FAST_FLASH_BOOT)\nSaved PC:0x40380700\nSPIWP:0xee\nmode:DIO, clock div:1\nload:0x3fcd5820,len:0x1738\nload:0x403cc710,len:0xb9c\nload:0x403ce710,len:0x2e40\nentry 0x403cc71a\nI (35) boot: ESP-IDF v5.3-dev-2815-gbe06a6f5ff 2nd stage bootloader\nI (35) boot: compile time Apr 14 2024 13:28:16\nI (36) boot: chip revision: v0.3\nI (40) boot.esp32c3: SPI Speed      : 80MHz\nI (45) boot.esp32c3: SPI Mode       : DIO\nI (49) boot.esp32c3: SPI Flash Size : 2MB\nI (54) boot: Enabling RNG early entropy source...\nI (59) boot: Partition Table:\nI (63) boot: ## Label            Usage          Type ST Offset   Length\nI (70) boot:  0 nvs              WiFi data        01 02 00009000 00006000\nI (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000\nI (85) boot:  2 factory          factory app      00 00 00010000 00100000\nI (93) boot: End of partition table\nI (97) esp_image: segment 0: paddr=00010020 vaddr=3c0c0020 size=0d884h ( 55428) map\nI (114) esp_image: segment 1: paddr=0001d8ac vaddr=3fc89400 size=00f74h (  3956) load\nI (115) esp_image: segment 2: paddr=0001e828 vaddr=40380000 size=017f0h (  6128) load\nI (123) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=b7cb4h (752820) map\nI (248) esp_image: segment 4: paddr=000d7cdc vaddr=403817f0 size=07a04h ( 31236) load\nI (257) boot: Loaded app from partition at offset 0x10000\nI (257) boot: Disabling RNG early entropy source...\nI (269) cpu_start: Unicore app\nI (278) cpu_start: Pro cpu start user code\nI (278) cpu_start: cpu freq: 160000000 Hz\nI (278) app_init: Application information:\nI (281) app_init: Project name:     main\nI (285) app_init: App version:      a36153d-dirty\nI (291) app_init: Compile time:     Apr 14 2024 13:28:13\nI (297) app_init: ELF file SHA256:  99b26c75b...\nI (302) app_init: ESP-IDF:          v5.3-dev-2815-gbe06a6f5ff\nI (308) efuse_init: Min chip rev:     v0.3\nI (313) efuse_init: Max chip rev:     v1.99\nI (318) efuse_init: Chip rev:         v0.3\nI (323) heap_init: Initializing. RAM available for dynamic allocation:\nI (330) heap_init: At 3FC8B320 len 00034CE0 (211 KiB): RAM\nI (336) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM\nI (343) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM\nI (350) heap_init: At 50000200 len 00001DE8 (7 KiB): RTCRAM\nI (357) spi_flash: detected chip: generic\nI (361) spi_flash: flash io: dio\nW (365) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.\nI (378) sleep: Configure to isolate all GPIO pins in sleep state\nI (385) sleep: Enable automatic switching of GPIO sleep configuration\nI (392) main_task: Started on CPU0\nI (402) main_task: Calling app_main()\nLoading ncnn mnist model...Done.\nPreparing input...Start Mesuring!\nDone!\n0: -1.63\n1: 3.05\n2: 12.36\n3: 7.95\n4: -17.89\n5: -9.99\n6: -15.13\n7: 16.36\n8: 0.45\n9: -3.34\nI think it is number 7!\nLatency, avg: 105.66ms, max: 105.71, min: 105.64. Avg Flops: 7.38MFlops\nRestarting now.\n```\n\n### esp32c6\n\n```\nESP-ROM:esp32c6-20220919\nBuild:Sep 19 2022\nrst:0xc (SW_CPU),boot:0xc (SPI_FAST_FLASH_BOOT)\nSaved PC:0x4001975a\nSPIWP:0xee\nmode:DIO, clock div:2\nload:0x40875720,len:0x1804\nload:0x4086c110,len:0xe2c\nload:0x4086e610,len:0x2e30\nentry 0x4086c11a\nI (22) boot: ESP-IDF v5.3-dev-2815-gbe06a6f5ff 2nd stage bootloader\nI (23) boot: compile time Apr 14 2024 11:52:36\nI (24) boot: chip revision: v0.0\nI (26) boot.esp32c6: SPI Speed      : 80MHz\nI (31) boot.esp32c6: SPI Mode       : DIO\nI (36) boot.esp32c6: SPI Flash Size : 2MB\nI (41) boot: Enabling RNG early entropy source...\nI (46) boot: Partition Table:\nI (50) boot: ## Label            Usage          Type ST Offset   Length\nI (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000\nI (64) boot:  1 phy_init         RF data          01 01 0000f000 00001000\nI (72) boot:  2 factory          factory app      00 00 00010000 00100000\nI (79) boot: End of partition table\nI (83) esp_image: segment 0: paddr=00010020 vaddr=420b0020 size=0a9e0h ( 43488) map\nI (110) esp_image: segment 1: paddr=0001aa08 vaddr=40800000 size=05610h ( 22032) load\nI (122) esp_image: segment 2: paddr=00020020 vaddr=42000020 size=aa960h (698720) map\nI (407) esp_image: segment 3: paddr=000ca988 vaddr=40805610 size=03e74h ( 15988) load\nI (416) esp_image: segment 4: paddr=000ce804 vaddr=40809490 size=00f64h (  3940) load\nI (424) boot: Loaded app from partition at offset 0x10000\nI (425) boot: Disabling RNG early entropy source...\nI (436) cpu_start: Unicore app\nI (446) cpu_start: Pro cpu start user code\nI (446) cpu_start: cpu freq: 160000000 Hz\nI (447) app_init: Application information:\nI (449) app_init: Project name:     main\nI (454) app_init: App version:      a36153d-dirty\nI (459) app_init: Compile time:     Apr 14 2024 11:52:33\nI (465) app_init: ELF file SHA256:  0a0e007ce...\nI (470) app_init: ESP-IDF:          v5.3-dev-2815-gbe06a6f5ff\nI (477) efuse_init: Min chip rev:     v0.0\nI (482) efuse_init: Max chip rev:     v0.99\nI (487) efuse_init: Chip rev:         v0.0\nI (491) heap_init: Initializing. RAM available for dynamic allocation:\nI (499) heap_init: At 4080B3B0 len 00071260 (452 KiB): RAM\nI (505) heap_init: At 4087C610 len 00002F54 (11 KiB): RAM\nI (511) heap_init: At 50000000 len 00003FE8 (15 KiB): RTCRAM\nI (518) spi_flash: detected chip: generic\nI (522) spi_flash: flash io: dio\nW (526) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.\nI (539) sleep: Configure to isolate all GPIO pins in sleep state\nI (546) sleep: Enable automatic switching of GPIO sleep configuration\nI (553) coexist: coex firmware version: d96c1e51f\nI (558) coexist: coexist rom version 5b8dcfa\nI (563) main_task: Started on CPU0\nI (563) main_task: Calling app_main()\nLoading ncnn mnist model...Done.\nPreparing input...Start Mesuring!\nDone!\n0: -1.63\n1: 3.05\n2: 12.36\n3: 7.95\n4: -17.89\n5: -9.99\n6: -15.13\n7: 16.36\n8: 0.45\n9: -3.34\nI think it is number 7!\nLatency, avg: 78.77ms, max: 79.48, min: 78.68. Avg Flops: 9.90MFlops\nRestarting now.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnihui%2Fncnn_on_esp32","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnihui%2Fncnn_on_esp32","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnihui%2Fncnn_on_esp32/lists"}