|
本帖最后由 iamseer 于 2022-11-23 10:01 编辑
分享一下我之前用openmv(stm32的魔改板)的经验。
首先把micropython的源代码下好,确定能编译使用。
然后在main.c里注释掉
pyb_usb_init0()
usbdbg_init()
把Run boot script(s)部分注释掉,把REPL启动注释掉。
建立
static vstr_t codeStr;
static const char code_main_py[] = 你的python代码
然后在本来Run boot script(s)的地方加入:
- vstr_add_str(&codeStr,code_main_py);
- nlr_buf_t nlr;
- if (nlr_push(&nlr) == 0) {
- // Execute the script.
- pyexec_str(&codeStr);
- nlr_pop();
- }
复制代码
这样的话你的固件就没有USB功能,也没有REPL,不能直接往外读代码。然后把固件烧到芯片里开上加密就行。
我猜更极端一点你可以把python代码加密,然后在送pyexec_str前用chipid解密,这样就算读出flash也不能一眼看出你的代码在哪。
|
|