一、板卡介绍
BeagleBone Black是一款小型、强大的开源单板计算机,广泛应用于教育、开发和原型设计领域。它由BeagleBoard.org基金会推出,旨在为开发者提供一个低成本、高效能的平台,以实现广泛的嵌入式应用开发。
BeagleBone Black配备了一颗AM335x 1GHz ARM Cortex-A8处理器,辅以512MB DDR3 RAM和4GB 8-bit eMMC存储器。其较为强劲的处理能力使其能够运行复杂的嵌入式系统和图像处理任务。此外,该板具有强大的图形处理能力,集成了PowerVR SGX530 GPU,支持3D加速,使其在图形显示和用户界面设计方面更具优势。
在连接性和扩展性方面,BeagleBone Black提供了丰富的接口选择。这包括一个10/100 Mbps以太网端口、micro HDMI、两个USB 2.0主机端口和一个USB客户端端口。其还支持通过microSD卡扩展存储。此外,BeagleBone Black拥有两个46针的扩展插头,提供多达92个引脚进行I/O扩展,包括GPIO、UART、I2C、SPI和A/D转换器,使其在外部硬件的连接和交互上具有广泛的灵活性。
该板默认运行Linux操作系统,通常预装Debian,并支持多种其他操作系统,包括Android和Ubuntu等。这种开源软件的支持,使开发者可以轻松访问和修改系统内核,满足特定的项目需求。
由于其功能强大、价格低廉,并且拥有广泛的社区支持和丰富的在线资源,BeagleBone Black成为了开发者和爱好者的热门选择。无论是用作学习工具还是实际项目开发的基础,BeagleBone Black都凭借其兼具实用性和灵活性的特点,为全球用户广泛接受和使用。
附一张板卡平铺图与板卡关键芯片解读图
二、任务解析
这里我选择的是任务2 在系统中建立一个网页,并且与LED联动,使用网线连接到设备上时,可以从网页中控制LED的开关与闪烁
我们首先对任务进行拆解
1. 设置开发环境 2. 安装Web服务器 3. 设置CGI或动态网页 4. 编写控制LED的脚本 5. 编写网页前端 6. 访问和测试
接下来我们一个个进行分析整板流图如下
%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3BjumpStyle%3Darc%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3B%22%20edge%3D%221%22%20source%3D%223%22%20target%3D%225%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22%E5%BC%80%E6%9C%BA%E5%88%9D%E5%A7%8B%E5%8C%96%22%20style%3D%22rounded%3D1%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%2290%22%20y%3D%22290%22%20width%3D%22120%22%20height%3D%2260%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%224%22%20value%3D%22%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3BjumpStyle%3Darc%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3B%22%20edge%3D%221%22%20source%3D%225%22%20target%3D%229%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%225%22%20value%3D%22%E5%90%AF%E5%8A%A8web%E6%9C%8D%E5%8A%A1%E5%99%A8%22%20style%3D%22rounded%3D1%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22270%22%20y%3D%22290%22%20width%3D%22120%22%20height%3D%2260%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%226%22%20value%3D%22%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3BjumpStyle%3Darc%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3B%22%20edge%3D%221%22%20source%3D%229%22%20target%3D%2211%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%227%22%20value%3D%22%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3BjumpStyle%3Darc%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3B%22%20edge%3D%221%22%20source%3D%229%22%20target%3D%2212%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%228%22%20value%3D%22%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3BjumpStyle%3Darc%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3B%22%20edge%3D%221%22%20source%3D%229%22%20target%3D%2213%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%229%22%20value%3D%22%E4%BD%BF%E7%94%A8py%E8%84%9A%E6%9C%AC%E5%BE%AA%E7%8E%AF%E6%A3%80%E6%B5%8Bweb%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%BF%A1%E6%81%AF%22%20style%3D%22rhombus%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22210%22%20y%3D%22380%22%20width%3D%22240%22%20height%3D%22100%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2210%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3BjumpStyle%3Darc%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3BentryX%3D0.509%3BentryY%3D0%3BentryDx%3D0%3BentryDy%3D0%3BentryPerimeter%3D0%3B%22%20edge%3D%221%22%20source%3D%2211%22%20target%3D%229%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%3E%3CmxPoint%20x%3D%22540%22%20y%3D%22555%22%20as%3D%22targetPoint%22%2F%3E%3C%2FmxGeometry%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2211%22%20value%3D%22%E6%97%A0%E4%BF%A1%E6%81%AF%22%20style%3D%22rounded%3D1%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22270%22%20y%3D%22525%22%20width%3D%22120%22%20height%3D%2260%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2212%22%20value%3D%22%E7%81%AF%E5%85%B3%E9%97%AD%22%20style%3D%22rounded%3D1%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22520%22%20y%3D%22400%22%20width%3D%22120%22%20height%3D%2260%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2213%22%20value%3D%22%E7%81%AF%E4%BA%AE%E8%B5%B7%22%20style%3D%22rounded%3D1%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%2230%22%20y%3D%22400%22%20width%3D%22120%22%20height%3D%2260%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2214%22%20value%3D%22%E7%81%AF%E9%97%AA%E7%83%81%22%20style%3D%22rounded%3D1%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%2230%22%20y%3D%22490%22%20width%3D%22120%22%20height%3D%2260%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2215%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3BjumpStyle%3Darc%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3BentryX%3D1.005%3BentryY%3D0.509%3BentryDx%3D0%3BentryDy%3D0%3BentryPerimeter%3D0%3B%22%20edge%3D%221%22%20source%3D%229%22%20target%3D%2214%22%20parent%3D%221%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2216%22%20value%3D%22%26lt%3Bspan%20style%3D%26quot%3Bwhite-space%3A%20pre-wrap%3B%26quot%3B%20class%3D%26quot%3BtokenSelector%26quot%3B%26gt%3Bon%26lt%3B%2Fspan%26gt%3B%22%20style%3D%22text%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3BwhiteSpace%3Dwrap%3Brounded%3D0%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22150%22%20y%3D%22400%22%20width%3D%2260%22%20height%3D%2230%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2217%22%20value%3D%22off%22%20style%3D%22text%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3BwhiteSpace%3Dwrap%3Brounded%3D0%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22450%22%20y%3D%22400%22%20width%3D%2260%22%20height%3D%2230%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2218%22%20value%3D%22%26lt%3Bspan%20style%3D%26quot%3Bwhite-space%3A%20pre-wrap%3B%26quot%3B%20class%3D%26quot%3BtokenSelector%26quot%3B%26gt%3Bblink%26lt%3B%2Fspan%26gt%3B%22%20style%3D%22text%3Bhtml%3D1%3Balign%3Dcenter%3BverticalAlign%3Dmiddle%3BwhiteSpace%3Dwrap%3Brounded%3D0%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22170%22%20y%3D%22495%22%20width%3D%2260%22%20height%3D%2230%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3
1、首先是开发环境的设置
使用一根以太网线链接BBB与电脑并通过SSH连接进入BBB 确保网络连接正常(网线连接或通过共享的USB网络连接)。执行
sudo apt-get update
sudo apt-get upgrade。
2、然后是 安装Web服务器
这里我选择的是轻量级服务器Lighttpd使用命令
sudo apt-get install lighttpd。
安装完成后,Lighttpd应该自动启动若未启动可以使用命令
sudo service lighttpd start
3、现在设置CGI模块
然后配置CGI编辑Lighttpd配置文件以启用CGI模块
/etc/lighttpd/lighttpd.conf中添加 server.modules += ( "mod_cgi" )。
创建一个执行文件的目录
/usr/lib/cgi-bin/。
4、对脚本文件进行编写
在你的CGI目录中,创建一个控制LED的Python脚本,control_led.py,
使用Adafruit_BBIO或类似的库来控制BeagleBone Black上的GPIO以操作LED。
form = cgi.FieldStorage()
action = form.getvalue('action')
if action == "on":
GPIO.output(LED_PIN, GPIO.HIGH)
elif action == "off":
GPIO.output(LED_PIN, GPIO.LOW)
elif action == "blink":
print("Content-type: text/html\n")
print("<html><body><h1>LED Control</h1></body></html>")
使用如下代码即可执行该脚本文件
chmod +x control_led.py
5、我们现在编写网页前端
在 /var/www/html/
目录下创建一个HTML文件,index.html
,用于提供控制界面。
<html>
<body>
<h1>LED Control Panel</h1>
<form action="/cgi-bin/control_led.py" method="get">
<input type="submit" name="action" value="on"> Turn On<br>
<input type="submit" name="action" value="off"> Turn Off<br>
<input type="submit" name="action" value="blink"> Blink<br>
</form>
</body>
</html>
6、测试与访问
在浏览器中输入BeagleBone Black的IP地址我这里是http://192.168.7.2/index.html
三、本次活动的收获
通过这次活动我学习了如何对linux类的开发板进行开发,了解了Linux内核机制与脚本运行原理,并且对如何生成一个简单的网页有了自己的理解,感谢硬禾科技与德捷电子给我这次项目机会,后续我将会继续完善该项目,当前计划对网站的页面进行美化 并且通过web服务器来控制更多板卡上的硬件,希望能做好可视化控制板卡上每一个GPIO引脚的逻辑状态 并且在web端实现类似逻辑分析仪的功能,最后再次感谢硬禾科技与德捷电子,希望活动越办越好。大家均能拿到想学习的板卡套件!