buildroot 添加 net-snmp
###工作目录:
/home/sam5d2/mytest/buildroot/buildroot-2017.02.2/output/images
编译时间长度为大于1个小时
#make menuconfig
###python配置:
/home/sam5d2/mytest/buildroot/buildroot-2017.02.2/output/images
1.建立一个目录:buildroot/
mkdir –p buildroot
2. tar xvf buildroot-2017.02.2.tar.gz –C buildroot/
3.tar xvf sama5d2_buildroot.tar -C buildroot/
4.ls buildroot/
4.cd buildroot/sama5d2_buildroot
5. ./ do_cmd.sh
6.cd ../ buildroot-2017.02.2/
7.make
如果要保存改动:
#make savedefconfig
#make busybox-update-config
#make uclibc-update-config
#cp .config ../sama5d2_buildroot/config/defconfig
#2017_06_06
修改python配置的话
#make menuconfig
#make clean
#make
然后在out目录下是新生成的image文件
#2018_01_10
增加了netsnmp选项
经过了make clean
要得到image文件 需要执行make
#2018-01-11
###遇到问题
[*] python-pysendfile
*** python-pysmb needs a toolchain w/ C++ ***
*** python-pysnmp needs a toolchain w/ C++ ***
*** python-pysnmp-apps needs a toolchain w/ C++ ***
*** python-pysnmp-libs needs a toolchain w/ C++ ***
###解决方法:
编译之后的文件系统为:
/home/sam5d2/mytest/buildroot/buildroot-2017.02.2/output/images/rootfs.tar
将rootfs.tar 解压到 另外一个目录下面:
sudo tar xvf rootfs.tar
进入 rootfs 里面执行如下命令:
sudo tar cvf usr.tar usr/
将usr.tar拷贝到 板子的root目录下,
进入板子root目录,
在板子中执行如下指令:
tar xvf usr.tar -C /
会自动覆盖 板子文件系统/usr目录下面的内容。
不能提前删除/usr目录,删除的话,会报错。缺少./rootfs/usr/lib/libtirpc.so.3
测试程序:snmp_test.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pysnmp.hlapi import *
errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(SnmpEngine(),
CommunityData('public', mpModel=0),
UdpTransportTarget(('demo.snmplabs.com', 161)),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)))
)
if errorIndication:
print(errorIndication)
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))
运行:
python snmp_test.py
运行结果:
SNMPv2-MIB::sysDescr.0 = Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686
1
buildroot交叉编译出现如下错误的时候:
You seem to have the current working directory in your
LD_LIBRARY_PATH environment variable. This doesn’t work.
support/dependencies/dependencies.mk:21: recipe for target ‘dependencies’ failed
make[1]: *** [dependencies] Error 1
Makefile:84: recipe for target ‘_all’ failed
make: *** [_all] Error 2
解决最有效的办法是:$ sudo make