操作系统:debian10。
uname -a
Linux mydebian 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux
按照手册网页的说明安装 microbit 模块。
https://microbit-micropython.readthedocs.io/en/latest/devguide/installation.html
sudo add-apt-repository -y ppa:team-gcc-arm-embedded
sudo add-apt-repository -y ppa:pmiller-opensource/ppa
sudo apt-get update
sudo apt-get install cmake ninja-build gcc-arm-none-eabi srecord libssl-dev
pip3 install yotta
为 module.json 设置配置。
{
"name": "helloyotta",
"version": "0.0.0",
"description": "Hello yotta example module",
"keywords": ["example"],
"author": "James Crosby <[email protected]>",
"homepage": "http://github.com/ARMmbed/yotta",
"repository": {
"url": "[email protected]:ARMmbed/helloyotta.git",
"type": "git"
},
"license": "Apache-2.0",
"dependencies": {
"simplelog": "~0.0.0"
},
"targetDependencies": {},
"bin": "./source"
}
构建固件:
yt target bbc-microbit-classic-gcc-nosd
运行 yotta update 来获取远程资产:
yt up
yt build
info: generate for target: bbc-microbit-classic-gcc-nosd 0.2.3 at /home/debian/yotta_targets/bbc-microbit-classic-gcc-nosd
warning: bin directory "source" doesn't exist but is listed in the module.json file of helloyotta 0.0.0 at /home/debian
warning: nothing to build!
CMake Deprecation Warning at CMakeLists.txt:16 (cmake_policy):
The OLD behavior for policy CMP0017 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
CMake Deprecation Warning at /usr/share/cmake-3.13/Modules/CMakeForceCompiler.cmake:69 (message):
The CMAKE_FORCE_C_COMPILER macro is deprecated. Instead just set
CMAKE_C_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
/home/debian/yotta_targets/mbed-gcc/CMake/toolchain.cmake:78 (cmake_force_c_compiler)
toolchain.cmake:8 (include)
CMakeFiles/3.13.4/CMakeSystem.cmake:6 (include)
CMakeLists.txt:97 (project)
CMake Deprecation Warning at /usr/share/cmake-3.13/Modules/CMakeForceCompiler.cmake:83 (message):
The CMAKE_FORCE_CXX_COMPILER macro is deprecated. Instead just set
CMAKE_CXX_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
/home/debian/yotta_targets/mbed-gcc/CMake/toolchain.cmake:79 (cmake_force_cxx_compiler)
toolchain.cmake:8 (include)
CMakeFiles/3.13.4/CMakeSystem.cmake:6 (include)
CMakeLists.txt:97 (project)
我的硬件信息:
Interface Version: 0255
Bootloader Version: 0255
下载并解压:
cd microbit-samples-master
yt clean
yt build
info: generate for target: bbc-microbit-classic-gcc-nosd 0.2.3 at /home/debian/Downloads/microbit-samples-master/yotta_targets/bbc-microbit-classic-gcc-nosd
CMake Deprecation Warning at CMakeLists.txt:16 (cmake_policy):
The OLD behavior for policy CMP0017 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
CMake Deprecation Warning at /usr/share/cmake-3.13/Modules/CMakeForceCompiler.cmake:69 (message):
The CMAKE_FORCE_C_COMPILER macro is deprecated. Instead just set
CMAKE_C_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
/home/debian/Downloads/microbit-samples-master/yotta_targets/mbed-gcc/CMake/toolchain.cmake:78 (cmake_force_c_compiler)
toolchain.cmake:8 (include)
/usr/share/cmake-3.13/Modules/CMakeDetermineSystem.cmake:94 (include)
CMakeLists.txt:73 (project)
CMake Deprecation Warning at /usr/share/cmake-3.13/Modules/CMakeForceCompiler.cmake:83 (message):
The CMAKE_FORCE_CXX_COMPILER macro is deprecated. Instead just set
CMAKE_CXX_COMPILER and allow CMake to identify the compiler.
Call Stack (most recent call first):
/home/debian/Downloads/microbit-samples-master/yotta_targets/mbed-gcc/CMake/toolchain.cmake:79 (cmake_force_cxx_compiler)
toolchain.cmake:8 (include)
/usr/share/cmake-3.13/Modules/CMakeDetermineSystem.cmake:94 (include)
CMakeLists.txt:73 (project)
GCC version is: 7.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
suppressing warnings from ble-nrf51822
suppressing warnings from nrf51-sdk
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
suppressing ALL warnings from mbed-classic, ble, ble-nrf51822 & nrf51-sdk
-- Configuring done
-- Generating done
-- Build files have been written to: /home/debian/Downloads/microbit-samples-master/build/bbc-microbit-classic-gcc-nosd
[114/172] Building CXX object ym/microbit-dal/source/CMakeFiles/microbit-dal.dir/core/MicroBitHeapAllocator.cpp.o
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/core/MicroBitHeapAllocator.cpp: In function 'void free(void*)':
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/core/MicroBitHeapAllocator.cpp:342:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if (*cb == 0 || *cb & MICROBIT_HEAP_BLOCK_FREE)
^~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/core/MicroBitHeapAllocator.cpp:345:10: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
*cb |= MICROBIT_HEAP_BLOCK_FREE;
^
[117/172] Building CXX object ym/microbit-dal/source/CMakeFiles/microbit-dal.dir/core/MicroBitFiber.cpp.o
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/core/MicroBitFiber.cpp: In function 'void scheduler_init(EventModel&)':
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/core/MicroBitFiber.cpp:189:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if (fiber_scheduler_running())
^~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/core/MicroBitFiber.cpp:194:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
messageBus = &_messageBus;
^~~~~~~~~~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/core/MicroBitFiber.cpp: In function 'int fiber_wait_for_event(uint16_t, uint16_t)':
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/core/MicroBitFiber.cpp:388:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(ret == MICROBIT_OK)
^~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/core/MicroBitFiber.cpp:391:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
return ret;
^~~~~~
[162/172] Building CXX object ym/microbit-dal/source/CMakeFiles/microbit-dal.dir/bluetooth/MicroBitIOPinService.cpp.o
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp: In member function 'void MicroBitIOPinService::onDataWritten(const GattWriteCallbackParams*)':
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:179:42: warning: array subscript is above array bounds [-Warray-bounds]
io.pin[i].getDigitalValue();
~~~~~~~~~~~~~~~~~~~~~~~~~^~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:182:41: warning: array subscript is above array bounds [-Warray-bounds]
io.pin[i].getAnalogValue();
~~~~~~~~~~~~~~~~~~~~~~~~^~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:199:41: warning: array subscript is above array bounds [-Warray-bounds]
io.pin[i].getDigitalValue();
~~~~~~~~~~~~~~~~~~~~~~~~~^~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:202:40: warning: array subscript is above array bounds [-Warray-bounds]
io.pin[i].getAnalogValue();
~~~~~~~~~~~~~~~~~~~~~~~~^~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:224:43: warning: array subscript is above array bounds [-Warray-bounds]
io.pin[pin].setAnalogValue(value);
~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:225:46: warning: array subscript is above array bounds [-Warray-bounds]
io.pin[pin].setAnalogPeriodUs(period);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:245:51: warning: array subscript is above array bounds [-Warray-bounds]
io.pin[data->pin].setDigitalValue(data->value);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:247:50: warning: array subscript is above array bounds [-Warray-bounds]
io.pin[data->pin].setAnalogValue(data->value == 255 ? 1023 : data->value << 2);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp: In member function 'void MicroBitIOPinService::updateBLEInputs(bool)':
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:136:50: warning: array subscript is above array bounds [-Warray-bounds]
value = io.pin[i].getDigitalValue();
~~~~~~~~~~~~~~~~~~~~~~~~~^~
/home/debian/Downloads/microbit-samples-master/yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:138:49: warning: array subscript is above array bounds [-Warray-bounds]
value = io.pin[i].getAnalogValue() >> 2;
~~~~~~~~~~~~~~~~~~~~~~~~^~
[172/172] Linking CXX executable source/microbit-samples
未找到.hex文件。
ls build/bbc-microbit-classic-gcc-nosd
build.ninja CMakeFiles CMakeLists.txt generated source ym yotta_config.h
CMakeCache.txt cmake_install.cmake CTestTestfile.cmake rules.ninja toolchain.cmake yotta_build_info.h yotta_config.json
现在在我的python3中:
python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import microbit
>>> dir(microbit)
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>>
我无法将 python3 的 REPL 用于 microbit。
答案1
您发布的示例输出显示构建系统正在寻找“源”目录以及要构建的文件。在本例中为 .cpp 文件。
你没有说你使用的是哪个版本的 micro:bit。以下建议对我在 Debian 上使用 v1 版本的 micro:bit 有用。
从 GitHub 上的兰卡斯特大学存储库下载 micro:bit 示例并解压:
https://github.com/lancaster-university/microbit-samples
microbit-samples-master 目录中有一个示例 main.cpp 文件和 .json 文件。examples 目录中还有其他示例 .cpp 文件。
在 microbit-samples-master 目录中:
yt target bbc-microbit-classic-gcc-nosd
yt clean
yt build
.hex 文件位于以下位置:
microbit-samples-master/build/bbc-microbit-classic-gcc/source