米尔T527开发板linux系统开机脚本
本帖最后由 米尔国产方案 于 2024-3-18 17:16 编辑米尔T527的开启自启动脚本可以使用/etc/init.d/S99user_startup
root@myd-lt527x-gk:/# ls /etc/init.d/
S01syslogd S30rpcbind S80dnsmasq
S02klogd S40network S90init
S02sysctl S40xorg S99swupdate_autorun
S10HDMI S50adb_start S99user_startup
S10udev S50sshd rcK
S20mdev S60nfs rcS
S20urandom S70MXAPP2
S30dbus S80bootplay
root@myd-lt527x-gk:/# cat /etc/init.d/S99user_startup
#!/bin/sh
echo "user startup xxx.sh"
root@myd-lt527x-gk:/#
通过启动脚本添加:wifi STA模式,上电自动连接路由器功能
本帖最后由 米尔国产方案 于 2024-3-18 18:44 编辑root@myd-lt527x-gk:/# vi /etc/init.d/S99user_startup
#!/bin/sh
echo "user startup xxx.sh"
#enable wifi
ifconfig wlan0 up
#set the wifi-AP SSID and password
wpa_passphrase OpenWrt 12345678 >> /etc/wpa_supplicant.conf
#shut down the wpa_supplicant process first
killall wpa_supplicant
#Initialize wpa_supplican
wpa_supplicant -B -Dnl80211 -c /etc/wpa_supplicant.conf -i wlan0
#Get ip address
udhcpc -b -i wlan0 -R
保存后,重启系统即可看到开发板wifi自动连接上路由器
通过启动脚本添加:设置网口mac地址
本帖最后由 米尔国产方案 于 2024-5-8 17:20 编辑#set eth mac address
ifconfig eth0 down
ifconfig eth0 hw ether 00:0C:29:36:97:20
ifconfig eth0 up
通过启动脚本添加:设置静态网口静态IP
本帖最后由 米尔国产方案 于 2024-5-8 17:19 编辑开发板网口默认为动态ip方式,用网线连接到路由器会自动获取ip。
但是需要直连PC机时,需要客户自己设置为静态ip。
ifconfig eth0 192.168.0.100 netmask 255.255.255.0 up
通过脚本设置网口静态IP,可以达到默认ip的作用。当应用程序未正确启动(加载网口配置参数)时,可以通过这个默认ip访问设备。
本帖最后由 米尔国产方案 于 2024-5-8 17:48 编辑
开启wifi的AP模式,电脑可以随时连接到开发板,并且通过网关地址(192.168.2.1)访问设备。
#当使用AP模式时,需要为激活wlan0并配置一个静态IP地址,这里配置一个默认的IP地址:192.168.2.1
ifconfig wlan0 192.168.2.1 up
#清除旧模式的配置,确保新模式正常执行,因为STA和AP模式配置不能同时存在。
killall udhcpc
killall udhcpd
killall wpa_supplicant
killall hostapd
#使用wlan0运行hostapd服务
hostapd -B /etc/hostapd.conf
另外,还需要编辑两个配置文件,设置AP的参数
/etc/hostapd.conf,该文件设置了wifi名和密码Ø ssid:wifi名称 Ø wpa_passphrase:wifi密码
root@myd-lt527:/# cat /etc/hostapd.conf interface=wlan0driver=nl80211ssid=myd_lt527_test_wifichannel=6hw_mode=gignore_broadcast_ssid=0auth_algs=1wpa=2wpa_passphrase=12345678wpa_key_mgmt=WPA-PSKwpa_pairwise=TKIPrsn_pairwise=CCMP
/etc/udhcpd.conf文件设置设备动态分配IP地址当AP模式配置完成,其它设备连接到这个热点时,就会通过wlan0获取到上面地址池中的IP地址,地址范围为192.168.2.10~192.168.2.254,子网掩码为255.255.255.0,默认网关192.168.2.1,DNS为8.8.8.8。
root@myd-lt527:/# cat /etc/udhcpd.conf # Change the following lines if you want dnsmasq to serve SRV# records.# You may add multiple srv-host lines.# The fields are <name>,<target>,<port>,<priority>,<weight> # A SRV record sending LDAP for the example.com domain to# ldapserver.example.com port 289#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389 # Two SRV records for LDAP, each with different priorities#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,1#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,2 # A SRV record indicating that there is no LDAP server for the domain# example.com#srv-host=_ldap._tcp.example.com # The following line shows how to make dnsmasq serve an arbitrary PTR# record. This is useful for DNS-SD.# The fields are <name>,<target>#ptr-record=_http._tcp.dns-sd-services,"New Employee Page._http._tcp.dns-sd-services" # Change the following lines to enable dnsmasq to serve TXT records.# These are used for things like SPF and zeroconf.# The fields are <name>,<text>,<text>... #Example SPF.#txt-record=example.com,"v=spf1 a -all" #Example zeroconf#txt-record=_http._tcp.example.com,name=value,paper=A4 # Provide an alias for a "local" DNS name. Note that this _only_ works# for targets which are names from DHCP or /etc/hosts. Give host# "bert" another name, bertrand# The fields are <cname>,<target>#cname=bertand,bertresolv-file=/etc/resolv.dnsmasq.confstrict-ordercache-size=102400interface=wlan0min-cache-ttl=3600dhcp-range=192.168.2.2,192.168.2.255all-serversdhcp-sequential-ip
root@myd-lt527:/# cat /etc/udhcpd.conf# Sample udhcpd configuration file (/etc/udhcpd.conf) # The start and end of the IP lease block start 192.168.2.10 #default: 192.168.2.20end 192.168.2.254 #default: 192.168.0.254 # The interface that udhcpd will use interface wlan0 #default: eth0 # The maximim number of leases (includes addressesd reserved# by OFFER's, DECLINE's, and ARP conficts #max_leases 254 #default: 254 # If remaining is true (default), udhcpd will store the time# remaining for each lease in the udhcpd leases file. This is# for embedded systems that cannot keep time between reboots.# If you set remaining to no, the absolute time that the lease# expires at will be stored in the dhcpd.leases file. #remaining yes #default: yes # The time period at which udhcpd will write out a dhcpd.leases# file. If this is 0, udhcpd will never automatically write a# lease file. (specified in seconds) #auto_time 7200 #default: 7200 (2 hours) # The amount of time that an IP will be reserved (leased) for if a # DHCP decline message is received (seconds). #decline_time 3600 #default: 3600 (1 hour) # The amount of time that an IP will be reserved (leased) for if an# ARP conflct occurs. (seconds #conflict_time3600 #default: 3600 (1 hour) # How long an offered address is reserved (leased) in seconds #offer_time 60 #default: 60 (1 minute) # If a lease to be given is below this value, the full lease time is# instead used (seconds). #min_lease 60 #defult: 60 # The location of the leases file #lease_file /var/lib/misc/udhcpd.leases #defualt: /var/lib/misc/udhcpd.leases # The location of the pid file#pidfile /var/run/udhcpd.pid #default: /var/run/udhcpd.pid # Everytime udhcpd writes a leases file, the below script will be called.# Useful for writing the lease file to flash every few hours. #notify_file #default: (no script) #notify_file dumpleases # <--- usefull for debugging # The following are bootp specific options, setable by udhcpd. #siaddr 192.168.0.22 #default: 0.0.0.0 #sname zorak #default: (none) #boot_file /var/nfs_root #default: (none) # The remainer of options are DHCP options and can be specifed with the# keyword 'opt' or 'option'. If an option can take multiple items, such# as the dns option, they can be listed on the same line, or multiple# lines. The only option with a default is 'lease'. #Examlesopt dns 202.96.134.133optionsubnet255.255.255.0opt router192.168.2.1opt wins 192.168.2.10optiondns 202.96.128.86 # appened to above DNS servers for a total of 3optiondomainlocaloptionlease 864000 # 10 days of seconds
页:
[1]