当前位置: 首页 > 工具软件 > NuttX > 使用案例 >

esp32c3 nuttx 移植 micropython 尝试

袁鸿畴
2023-12-01

源码来自

https://github.com/apache/incubator-nuttx-apps/pull/840

https://github.com/apache/incubator-nuttx-apps/tree/787ac90600c28b0edd52067e8a21a54635459f4e/interpreters/micropython
具体修改了哪些文件,可以从这个链接查看:
https://github.com/micropython/micropython/compare/master…mransom-campbell:micropython:nuttx

编译说明

<1>. 只能在 Linux(ubuntu) 下编译

osx下出现错误:clang: error: unknown argument: '-msmall-data-limit=0'
ricsv工具链下载地址:https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.12/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz

<2>. 修改Application.mk

将 OBJS 后的 = 改为 += so Applications can add their own object files manually.
否则在最后的ld阶段,会出现 micropython_main 未定义的错误

<3>. 编译tools/kconfig-frontends

./configure --enable-mconf
make
sudo make install
sudo ldconfig # 必须运行,否则会出现 libkconfig-parser-4.11.0.so 文件找不到的错误!

<4>. chown manfeel:manfeel /dev/ttyACM0

否则在部署阶段:
make download ESPTOOL_PORT=/dev/ttyACM0 ESPTOOL_BINDIR=../esp-bins
会因为权限不足无法继续(也可以通过rules文件修改,但我懒-_-)

<5>. 修改 arch/risc-v/src/esp32c3/esp32c3_usbserial.c

 #ifdef CONFIG_SERIAL_TERMIOS
 #  include <termios.h>
+#  include <nuttx/serial/tioctl.h>
 #endif

否则会出现两个宏未定义

目前还无法成功运行micropython

直接panic(但通过命令行参数可以执行命令!

MicroPython v1.16-147-g4db1898f5-dirty on 2022-08-18; nuttx version
Use Ctrl-D to exit, Ctrl-E for paste mode
riscv_exception: EXCEPTION: Illegal instruction. MCAUSE: 00000002
riscv_exception: PANIC!!! Exception = 00000002
up_assert: Assertion failed at file:common/riscv_exception.c line: 89 task: micropython
riscv_registerdump: EPC: 00000000
riscv_registerdump: A0: 3fc8f2e4 A1: 00000004 A2: 00000000 A3: 00000064
riscv_registerdump: A4: 00000038 A5: 00000000 A6: 00000048 A7: 0000003d
riscv_registerdump: T0: 42032efa T1: 0000000f T2: 00000000 T3: 00000000
riscv_registerdump: T4: 00000000 T5: 00000000 T6: 00000000
riscv_registerdump: S0: 3fc8f2e4 S1: 00000000 S2: 3fc86000 S3: 000003e8
riscv_registerdump: S4: 3fc8f2fc S5: 00000344 S6: 3fc8f2f6 S7: 3c0b2000
riscv_registerdump: S8: 3c0b7000 S9: 3c0b7000 S10: 3c0b3000 S11: 00000000
riscv_registerdump: SP: 3fc9e8f0 FP: 3fc8f2e4 TP: 00000000 RA: 42002b00
riscv_dump_stack: IRQ Stack:
riscv_dump_stack: sp:     3fc83cd0
riscv_dump_stack:   base: 3fc83750
riscv_dump_stack:   size: 00000600
riscv_stackdump: 3fc83cc0: 3fc85000 3c0b1000 3fc9e86c 42004768 3fc908fc 00001880 00000059 3c0b05e4
riscv_stackdump: 3fc83ce0: 3fc85198 00001880 3fc8f2fc 000003e8 3c0b0000 3fc9e86c 00000002 42002fa0
riscv_stackdump: 3fc83d00: 00000002 00000042 80000000 42000684 3fc86000 00000000 3fc85000 40382f62
riscv_stackdump: 3fc83d20: 00000000 00000000 00000000 4200078e 00000000 00000000 00000002 403801e4
riscv_dump_stack: User Stack:
riscv_dump_stack: sp:     3fc9e8f0
riscv_dump_stack:   base: 3fc9cb10
riscv_dump_stack:   size: 00001fc0
riscv_stackdump: 3fc9e8e0: 00000000 00000000 00000000 00001880 3c0b7000 3c0b7000 3c0b7000 3fc925c0
riscv_stackdump: 3fc9e900: 00000115 00000000 3fc8f2e4 42002c3c 00000000 00000115 3fc9ca60 4200f374
riscv_stackdump: 3fc9e920: 3c0b7000 00000000 3fc9ca60 4200edb0 00000005 00000005 3c0b7000 3c0b7000
riscv_stackdump: 3fc9e940: 3fc86a3c 00000115 00000000 4200f41a 00000018 00000000 3fc9e978 3fc9ca60
riscv_stackdump: 3fc9e960: 3fc9cad0 00000002 00000000 420592fa 00000001 3fc9caf0 00000000 3fc86a5c
riscv_stackdump: 3fc9e980: 3fc86a5c 00000001 00000048 0000003d 3c0b7000 3c0b7000 fffffffe 42020b46
riscv_stackdump: 3fc9e9a0: 90d94e13 00000000 5fdff20a 8afe7351 ac0098b7 00000060 3fc91cd0 42001770
riscv_stackdump: 3fc9e9c0: a2dc149b fb9675ec 3fc91cd0 42003f40 88173f2a 00000003 3fc9f170 42002004
riscv_stackdump: 3fc9e9e0: 82ae4f69 00000060 3fc9eae0 42004114 00000006 00000006 00000000 3fc85000
riscv_stackdump: 3fc9ea00: 00000006 3fc9ea64 00000088 42002256 00000010 00000000 3fc9f270 3fc9eae0
riscv_stackdump: 3fc9ea20: b82b6fb1 00000000 00000000 42003d4a 00000000 00001fc0 3fc9cad0 3fc9cb10
riscv_stackdump: 3fc9ea40: 00000000 3fc9c130 3fc86a00 42058d7c 00000000 00000000 42020cd2 42035bd0
riscv_stackdump: 3fc9ea60: 00000004 42020d3c 00000000 00000000 00000000 00000000 00000000 00000000
riscv_stackdump: 3fc9ea80: 00000000 00000000 00000000 00000000 00000000 00000000 42020cd2 42003082
riscv_stackdump: 3fc9eaa0: 00000000 00000000 3fc9caf0 00000001 00000000 00000000 00000000 42001164
riscv_showtasks:    PID    PRI     STACK   COMMAND
riscv_showtasks:   ----   ----      1536   irq
riscv_dump_task:      0      0      2016   Idle Task
riscv_dump_task:      1    224      1984   hpwork 0x3fc85280
riscv_dump_task:      2    100      1984   nsh_main
riscv_dump_task:      3    223      1984   rt_timer
riscv_dump_task:      4    253      6608   wifi
riscv_dump_task:      5    100      8128   micropython

 类似资料: