ubuntu 18.04 LTS server 安装遇到问题 and watchdog

参考资料:
https://blog.csdn.net/wowocpp/article/details/90295688

用到的镜像文件: ubuntu-18.04.2-live-server-amd64.iso

安装的时候,制作U盘启动工具是:

rufus-3.5p.exe

用到的 U盘 是一个8G的U盘

  1. 设置IP地址
  2. 重启的时间比较长
  3. 启动的时候时间比较长
  4. 分区问题,LVM 只用4G的问题
    Cloud init服务 是干嘛的

reboot 之后:
stopped LVM2 metadata daemon
时间过长

a starting job is Waiting for Network to be configured when start 18.04 ubuntu server version

/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service

add --timeout 5 after ExecStart line

a start job is running for wait for Network to be configured

stopped Monitoring of LVM2 mirrors,snapshots etc using dmeventd or progress polling

此时再次尝试ping外网。

tencab 66321

Huawei ME906s LTE M.2 Module

sudo vi /lib/systemd/system/systemd-networkd-wait-online.service

ExecStart=/lib/systemd/systemd-networkd-wait-online --timeout=10

touch /etc/cloud/cloud-init.disabled
add cloud-init=disabled to the kernel command line.

域名解析

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
(venv) openstack@beta-mo

GPIO 驱动

The directory names in /sys/class/gpio/ need to be identified with their hardware register counterparts. These directory names will have the form gpiochipN, where N is for the base GPIO number in that register. The file gpiochipN/label should help identify the register, e.g. by its (memory or port) address.

#include
//#include
#include 
#include 

#define    IT8786_GPIO_BASE_ADDRESS    0xA00
#define GPIO_ADDRESS    (IT8786_GPIO_BASE_ADDRESS + 0x07)  /* define base address of GPIO80-87 */
#define SIO_CONFIG_INDEX    0x2E  /* N29 SIO index register */
#define SIO_CONFIG_DATA        0x2F  /* N29 SIO data  register */

#define MAX_GPIO    8  /* GPIO80-87 */


void IoWrite8(unsigned short addr, int val) /* IO port WRITE function */
{
    //outp(addr, val);
	outb(val,addr);
}

int IoRead8(unsigned short addr) /* IO port READ function */
{
    return inb(addr);
}

/********************************************************************
*** When enter into GPIO configuration space, we need to EnterSio,
*** When leave out GPIO configuration space, we need to ExitSio,
*********************************************************************/ 
void EnterSio()
{
    IoWrite8(SIO_CONFIG_INDEX, 0x87);
    IoWrite8(SIO_CONFIG_INDEX, 0x01);
    IoWrite8(SIO_CONFIG_INDEX, 0x55);
    IoWrite8(SIO_CONFIG_INDEX, 0x55);
}

void ExitSio()
{
    IoWrite8(SIO_CONFIG_INDEX, 0x02);
    IoWrite8(SIO_CONFIG_DATA,  0x02);
}

int main()
{
    unsigned short Data8 = 0;
    int i;
    ioperm(0x000,0xAFF,1);
    EnterSio();

    IoWrite8(SIO_CONFIG_INDEX, 0x07);
    IoWrite8(SIO_CONFIG_DATA,  0x07);

    printf("************************************************************\n");
    printf("******************* N29 GPIO check tool ********************\n");
    printf("************************************************************\n");


    /* test if GPIO is avaliable */
    IoWrite8(SIO_CONFIG_INDEX, 0x2C);
    Data8 = IoRead8(SIO_CONFIG_DATA);

    /* printf("Data8 = %d\n", Data8); */

    if(!(Data8 & 0x80)) /* Not Avaliable */
    {
        printf("Error-The GPIO is NOT avaliable!\n");
        return 1;
    }
    

    for(i = 0; i < MAX_GPIO; i++)
    {
        /* test if the GPIO is INPUT or OUTPUT */
        IoWrite8(SIO_CONFIG_INDEX, 0xCF);
        Data8 = IoRead8(SIO_CONFIG_DATA);
        if(Data8 & (1 << i)) /* OUTPUT */
            printf("The GPIO8%d is Output ", i);
        else
            printf("The GPIO8%d is Input  ", i);

        /* test if the GPIO voltage is HIGH or LOW */
        Data8 = IoRead8(GPIO_ADDRESS);
        if(Data8 & (1 << i)) /* HIGH */
            printf("High.\n");
        else
            printf("Low.\n");
    }

    ExitSio();
    ioperm(0x000,0xAFF,0);
    return 0;

}

安装定时器:

crontab -e

*/1 * * * * sh /root/watchdogtask.sh

watchdogtask.sh

#!/bin/sh
/root/set_watch_dog
echo "1\n" >> /root/123.txt

Ubuntu查看crontab运行日志

http://www.pooy.net/ubuntu-open-crontab-logging-and-resolution-no-mta-installed-discarding-output-problem.html
在ubuntu下安装crontab后,系统默认的是不开启crontab的日志记录,如何开始crontab的日志:
修改rsyslog文件,将/etc/rsyslog.d/50-default.conf 文件中的#cron.*前的#删掉;
重启rsyslog服务service rsyslog restart;
重启cron服务service cron restart;
tail -f /var/log/cron.log;
就可以查看运行时的日志文件,如果在日志文件中出现:No MTA installed, discarding output
那么就是说,crontab执行脚本时是不会直接错误的信息输出,而是会以邮件的形式发送到你的邮箱里,这时候就需要邮件服务器了,如果你没有安装邮件服务器,它就会报这个错。如果是测试,可以用下面的办法来解决:
在每条定时脚本后面加入:
1>/dev/null 2>&1
就可以解决No MTA installed, discarding output的问题。

Ubuntu查看crontab运行日志

修改rsyslog

sudo vim /etc/rsyslog.d/50-default.conf
cron.* /var/log/cron.log #将cron前面的注释符去掉
重启rsyslog

sudo service rsyslog restart
查看crontab日志

tail -f /var/log/cron.log

cron 状态

service cron status

watchdog定时器脚本:
#include
//#include
#include 
#include 



void IoWrite8(unsigned short addr, int val) /* IO port WRITE function */
{
    //outp(addr, val);
   outb(val,addr);
}

int IoRead8(unsigned short addr) /* IO port READ function */
{
    return inb(addr);
}



int main()
{
    unsigned short Data8 = 0;
    int i;
	
	unsigned char Temp;
	
    ioperm(0x000,0xAFF,1);
	
    IoWrite8(0x2E, 0x87);
    IoWrite8(0x2E, 0x01);
    IoWrite8(0x2E, 0x55);
    IoWrite8(0x2E, 0x55);

	
	// select the watchdog
	IoWrite8(0x2E, 0x07);
	IoWrite8(0x2F, 0x07);
		
	
	// enable watchdog 
	IoWrite8(0x2E, 0x72);
	Temp = IoRead8(0x2F);
	printf("0x72 read value :0x%x,%d\n",Temp,Temp);

	IoWrite8(0x2F, 0x90); // bit7 = 1  and bit4 =1
	

	IoWrite8(0x2E, 0x73);
	Temp = IoRead8(0x2F);
	printf("0x73 = 0x%2x,%d\n",Temp,Temp);
	IoWrite8(0x2F, 80);



	IoWrite8(0x2E,0x02);
    IoWrite8(0x2F,0x02);

    ioperm(0x000,0xAFF,0);
	
    return 0;

}

注意其中的 bit7 =1 和 bit4 =1 ,为0x90 而不是 0xb0

gcc watch_dog_set.c -o set_watch_dog

bios 中 设置 BIOS 为 watchdog disable

停止 定时进程:

service cron stop
检测 看门狗 是否设置正确

complile_code.sh
#!/bin/sh
gcc  watch_dog_set.c -o set_watch_dog
chmod a+x set_watch_dog
安装python

sudo apt-get install python
安装上的是:
Python 2.7.15rc1

安装Python2.7:

1 //安装 Python 发布版本,dev包必须安装,很多用pip安装包都需要编译
2 sudo apt-get install python2.7 python2.7-dev
安装Python3.2:

1 //安装 Python 发布版本,dev包必须安装,很多用pip安装包都需要编译
2 sudo apt-get install python3.2 python3.2-dev
pip是Python的包管理工具,建议Python的所有包都用pip进行管理,命令如下:

1 //安装 pip
2 sudo apt-get install python-pip

sudo pip install virtualenv
Successfully installed virtualenv-16.6.0

virtualenv venv
创建python 环境
source venv/bin/activate

安装bacnet

http://bacpypes.sourceforge.net/

sudo apt-get install subversion

svn checkout https://svn.code.sf.net/p/bacpypes/code/trunk bacpypes

cd bacpypes/
(venv) bacnet@ubuntu:~/bacnet/bacpypes$ python setup.py install

enp3s0: flags=4163 mtu 1500
inet 192.168.99.181 netmask 255.255.255.0 broadcast 192.168.99.255
inet6 fe80::2e0:b4ff:fe1d:881c prefixlen 64 scopeid 0x20
ether 00:e0:b4:1d:88:1c txqueuelen 1000 (Ethernet)
RX packets 229765 bytes 69416287 (69.4 MB)
RX errors 0 dropped 48 overruns 0 frame 0
TX packets 26526 bytes 2273559 (2.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xd0700000-d071ffff

ubuntu 18.04 LTS server 安装遇到问题 and watchdog_第1张图片

你可能感兴趣的:(ubuntu)