maixpy韌體編譯筆記
maixpy最近新加了語音識別還有ussl,但都沒有提供官方編譯好的估計,於是要自己動手編譯一個了。
使用的編譯環境:centOS7
一、下載maxipy原始碼
git加速方法:
原來是使用git clone https://github.com/sipeed/MaixPy.git,但是巨慢,搜了一下可以在url前面加上gitclone.com/,可以加速一下。
ps:但是因為maxipy裡面有很多巢狀的submodule,每層巢狀的submodule都要改地址,這個方法太繁瑣了,下次看還是直接用代理算了
git clone https://gitclone.com/github.com/sipeed/MaixPy
進入專案的根目錄,手工更新第一層
cd MaixPy
vi .gitmodules #給每個github的地址加字首gitclone.com/
git submodule sync #因為修改了gitmodules配置檔案,需要sync重新整理同步一下
git submodule update --init #開始更新子模組
查詢子模組的子模組
cd MaixPy find ./ -name ".gitmodules" ./components/micropython/core/.gitmodules ./components/micropython/port/src/lvgl/lv_bindings/.gitmodules ./.gitmodules
進入每個子模組,迴圈更新子模組的子模組
vi .gitmodules
git submodule sync
git submodule update --init --recursive
但遇到有兩個submodule無法git下來,報錯:
error: 伺服器不允許請求未公開的物件 dc871acafc8b7e0823dee123b744c4edf52165d1 獲取了子模組路徑 'components/micropython/port/src/lvgl/lv_bindings/driver/png/lodepng' ,但是它沒有包含 dc871acafc8b7e0823dee123b744c4edf52165d1。直接獲取該提交失敗。 error: 伺服器不允許請求未公開的物件 ec68ba8208d7550860e4e78299d58a529b88bf85 獲取了子模組路徑 'components/spiffs/core',但是它沒有包含 ec68ba8208d7550860e4e78299d58a529b88bf85。直接獲取該提交失敗。
於是把lodepng和spiffs重新改回原來github的地址上,重新重新整理submodule配置然後update一下,成功。
git submodule sync
git submodule update --init --recursive
二、編譯maxipy原始碼
按照https://github.com/sipeed/MaixPy/blob/master/build.md一步步弄下來,編譯:
cd MaixPy
cd projects/maixpy_k210
python3 project.py menuconfig
python3 project.py build
報錯 1、提示找不到global_build_info_version.h檔案
解決方法:
重新初始化
python3 project.py distclean
生成配置檔案,選擇需要的包,比如lvgl、speech、ussl等
python3 project.py menuconfig
手動生成標頭檔案global_build_info_version.h
cd project/maixpy_k210
python3 ../../tools/kconfig/update_build_info.py --configfile header build/config/global_build_info_time.h build/config/global_build_info_version.h
報錯 2、遇到編碼錯誤
GEN build/genhdr/mpversion.h
GEN build/genhdr/moduledefs.h
GEN build/genhdr/qstr.i.last
GEN build/genhdr/qstr.split
Traceback (most recent call last):
File "../py/makeqstrdefs.py", line 113, in <module>
process_file(infile)
File "../py/makeqstrdefs.py", line 32, in process_file
for line in f:
File "/usr/lib64/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 45: invalid continuation
byte
編輯makeqstrdefs.py檔案,把最後的utf8改為本機編碼,比如gbk
vi /data1/maixpy/MaixPy/components/micropython/core/py/makeqstrdefs.py
if args.command == "split":
with io.open(args.input_filename, encoding='gbk') as infile:
然後重新編譯指定的配置檔案
python3 project.py build --config_file "config_with_lvgl.mk"
成功
-- Generating .bin firmware at /maixpy/MaixPy/projects/maixpy_k210/build/maixpy.bin
============= firmware =============
text data bss dec hex filename
2706487 39011 1702560 4448058 43df3a /data1/maixpy/MaixPy/projects/maixpy_k210/build/maixpy.elf
[100%] Built target maixpy
==================================
time: Fri Oct 30 13:41:13 2020
build end, time last:178.36s
==================================