我正在使用xorg运行Ubuntu22.04。我需要找到一种方法,在本地编译微比特python代码到固件十六进制文件。首先,我跟着导游来了https://microbit-micropython.readthedocs.io/en/latest/devguide/flashfirmware.html。
经过大量的调试,我到了这一点:https://pastebin.com/MGShD31N
但是,文件platform.h确实存在。
sawntoe@uwubuntu:~/Documents/Assignments/2022/TVP/micropython$ ls /home/sawntoe/Documents/Assignments/2022/TVP/micropython/yotta_modules/mbed-classic/api/platform.h
/home/sawntoe/Documents/Assignments/2022/TVP/micropython/yotta_modules/mbed-classic/api/platform.h
sawntoe@uwubuntu:~/Documents/Assignments/2022/TVP/micropython$ 在这一点上,我放弃了这一点,并尝试使用Mu编辑器与AppImage。然而,Mu需要wayland,我在xorg上。
有没有人知道这是可能的?谢谢。
发布于 2022-08-20 11:15:03
好吧,那么详细介绍彼得·蒂尔的答案。
首先,您可以使用uflash:
uflash path/to/your/code .或者,您可以使用microfs:
ufs put path/to/main.py发布于 2022-08-20 09:04:28
Mu和uflash命令能够从.hex文件中检索您的Python代码。例如,使用uflash可以执行以下操作:
uflash my_script.py我认为你想要做的事情是可能的,但它比仅仅使用他们的web python编辑器:https://python.microbit.org/v/2更难。
发布于 2022-08-22 09:24:23
彼得·泰尔回答了原来的问题。下面的附加内容通过展示如何自动化构建和加载过程来增加这个答案。我用Debian。最初的问题是使用Ubuntu,它建立在Debian上。
查找和挂载微:位的脚本
当代码加载到微:位时,板将从系统中卸下。所以每次你有新的代码要加载,你必须重新安装板。
我修改了一个脚本,以找到并挂载微:位。
#!/bin/bash
BASEPATH="/media/$(whoami)/"
MICRO="MICROBIT"
if [ $# -eq 0 ]
then
echo "no argument supplied, use 'mount' or 'unmount'"
exit 1
fi
if [ $1 == "--help" ]
then
echo "mounts or unmounts a BBC micro:bit"
echo "args: mount - mount the microbit, unmout - unmount the microbit"
fi
# how many MICRO found in udiksctl dump
RESULTS=$(udisksctl dump | grep IdLabel | grep -c -i $MICRO)
case "$RESULTS" in
0 ) echo "no $MICRO found in 'udkisksctl dump'"
exit 0
;;
1 ) DEVICELABEL=$(udisksctl dump | grep IdLabel | grep -i $MICRO | cut -d ":" -f 2 | sed 's/^[ \t]*//')
DEVICE=$(udisksctl dump | grep -i "IdLabel: \+$DEVICELABEL" -B 12 | grep " Device:" | cut -d ":" -f 2 | sed 's/^[ \t]*//')
DEVICEPATH="$BASEPATH""$DEVICELABEL"
echo "found one $MICRO, device: $DEVICE"
if [[ -z $(mount | grep "$DEVICE") ]]
then
echo "$DEVICELABEL was unmounted"
if [ $1 == "mount" ]
then
udisksctl mount -b "$DEVICE"
exit 0
fi
else
echo "$DEVICELABEL was mounted"
if [ $1 == "unmount" ]
then
udisksctl unmount -b "$DEVICE"
exit 0
fi
fi
;;
* ) echo "more than one $MICRO found"
;;
esac
echo "exiting without doing anything"我在我的文件中将这个脚本化名为mm。
自动安装微:位并闪烁python文件
我使用inotifywait命令来运行mm,然后运行uflash来加载我正在处理的.py文件。每次保存python文件时,都会运行别名命令mm和uflash命令。
while inotifywait -e modify <your_file>.py ; do mm && uflash <your_file>.py ; donehttps://stackoverflow.com/questions/73425359
复制相似问题