Makefile

cc = arm-himix200-linux-gcc
prom = psdk_com
deps = $(shell find ./ -name “*.h”)
src = $(shell find ./ -name “*.c”)
obj = $(src:%.c=%.o)

root_dir = $(shell pwd)

ccflags = -lpthread -I$(root_dir)

$(prom): $(obj)
$(cc) $(ccflags) -o $(prom) $(obj)

%.o: %.c $(deps)
$(cc) $(ccflags) -c $< -o $@ clean: rm -rf $(obj) $(prom)

串口文件传输协议

所有数据以小端模式传输,字符串为UTF8编码

报文格式定义
命令 长度 数据 校验
uint8 uint8 uint16 uint8[] uint16
0xAA 见命令定义 后面数据段的长度0~65535 数据内容,字节数组 标准modbusCRC16校验
基础命令定义
命令名称 命令值 数据内容 数据长度 响应命令 响应内容 响应长度 备注
握手 0x01 0xAA 0xBB 0xCC 0xDD 固定长度4 0x81 0xAA 0xBB 0xCC 0xDD 固定长度4
时间同步 0x10 unix时间戳(uint32) 固定长度4 0x90 成功返回1,失败返回0(uint8) 固定长度1 此命令一般由主机每秒发一次,可以回复,也可以不回复
文件命令定义
命令名称 命令值 数据内容 数据长度 响应命令 响应内容 响应长度 备注
打开文件 0x02 完整的文件路径,字符串形式 字符串长度 0x82 文件描述符,sint32,<0表示打开失败 固定长度4 以读写方式打开文件,文件不存在则返回-1
读取文件 0x03 文件描述符(sint32)+读取位置(uint32)+读取数据最大长度(uint16) 固定长度10 0x83 实际数据长度(uint16)+数据内容 2+数据长度
创建文件 0x04 完整的文件路径,字符串形式 字符串长度 0x84 文件描述符,sint32,<0表示创建失败 固定长度4 文件存在则以读方式直接打开,不存在则创建
写入文件 0x05 文件描述符(sint32)+写入数据长度(uint16)+写入数据 6+数据长度 0x85 实际写入数据长度(uint16) 固定长度2 以追加方式写入
删除文件 0x06 完整的文件路径,字符串形式 字符串长度 0x86 uint8,1代表成功,0代表失败 固定长度1
关闭文件 0x07 文件描述符(sint32) 固定长度4 0x87 uint8,1代表成功,0代表失败 固定长度1
获取文件信息 0x08 完整的文件路径,字符串形式 字符串长度 0x88 文件是否可用(uint8)+文件大小(uint32)+创建时间戳(uint32)+修改时间戳(uint32) 固定长度13 如果文件不可用,则其他信息无效
控制命令定义
命令名称 命令值 数据内容 数据长度 响应命令 响应内容 响应长度 备注
通道触发指令 0x11 通道(uint8)+触发序号(uint32),每位代表一个通道 固定长度1 0x91 返回(uint8),成功相应通道置1,失败为置0 固定长度1 此命令必须回复,执行失败则主机会重发
反馈事件上报 0x12 事件个数(uint8)+[触发序号(uint32)+反馈通道(uint8)+反馈时间(uint32)] 1+事件个数*5 0x92 成功返回1,失败返回0(uint8) 固定长度1 此命令必须回复,执行失败需要重发
云台控制 0x13 待定 待定 0x93 待定 待定 此命令必须回复,执行失败需要重发

linux nfs

服务端:
安装
sudo apt-get install nfs-kernel-server # 安装 NFS服务器端
sudo apt-get install nfs-common # 安装 NFS客户端

修改
sudo vim /etc/exports
如下:
/media/server_disk/nfs *(rw,sync,no_root_squash,no_subtree_check)

客户端:
mount -t nfs 192.168.8.200:/media/server_disk/nfs /mnt/nfs

由于ubuntu上mount -tcifs 必须使用sudo,挂载后目录属于root,其他用户无写入权限
可以挂载指定用户来解决:
sudo mount -t cifs //192.168.8.200/OfficeServer ./OfficeServer -o username=leon,password=123456,uid=1000,gid=1000

HI3516EV300 开启串口1和串口2

参考:https://blog.csdn.net/sbddbfm/article/details/100883650
SDK默认只打开了uart0,但我实际上要用三个串口。
ls /dev/ttyAMA*可以看到:
/dev/ttyAMA0 /dev/ttyAMA1
看实际只有ttyAMA0可以用,也就是上电默认的终端
使用echo测试:
~ # echo 123 > /dev/ttyAMA0
123

~ # echo 123 > /dev/ttyAMA1
can not create file:/dev/ttyAMA1

首先看内核配置文件arch/arm/boot/dts/hi3516ev300.dtsi:
uart0: uart@12040000 {
compatible = “arm,pl011”, “arm,primecell”;
reg = <0x12040000 0x1000>;
interrupts = <0 7 4>;
clocks = <&clock HI3516EV300_UART0_CLK>;
clock-names = “apb_pclk”;
status = “disabled”;
};

uart1: uart@12041000 {
compatible = “arm,pl011”, “arm,primecell”;
reg = <0x12041000 0x1000>;
interrupts = <0 8 4>;
clocks = <&clock HI3516EV300_UART1_CLK>;
clock-names = “apb_pclk”;
status = “disabled”;
};

uart2: uart@12042000 {
compatible = “arm,pl011”, “arm,primecell”;
reg = <0x12042000 0x1000>;
interrupts = <0 9 4>;
clocks = <&clock HI3516EV300_UART2_CLK>;
clock-names = “apb_pclk”;
status = “disabled”;
};
可见是有个串口的,但都是disable的状态,其实起作用的是另一个文件: arch/arm/boot/dts/hi3516ev300-demb.dts:
&uart0 {
status = “okay”;
};
所以再copy两份就可以了,在下面添加:
&uart1 {
status = “okay”;
};
&uart2 {
status = “okay”;
};
重新编译内核,下载到目标板,启动后ls /dev/ttyAMA*可以看到:
/dev/ttyAMA0 /dev/ttyAMA1 /dev/ttyAMA2
echo测试都可以成功,但与实际串口相连的设备没有收到数据,查资料得知,还得配置引脚复用寄存器。

使用hisi工具btools,具体使用方法可参考另一文章:

我的板子串口发送接在E1脚
查文档如下:

默认值为0x1E00,应该修改为0x1E04
使用himd.l读取寄存器的值:
~ # himd.l 0x120C0014
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:168}cmdstr:himd.l
====dump memory 0x120C0014====
0000: 00001e00 00001d00 00001400 00001d00
0010: 00000000 00000000 00000000 00000000
0020: 00000000 00000000 00000000 00000000
0030: 00000000 00000000 00000000 00000000
0040: 00000000 00000000 00000000 00000000
0050: 00000000 00000000 00000000 00000000
0060: 00000000 00000000 00000000 00000000
0070: 00000000 00000000 00000000 00000000
0080: 00000000 00000000 00000000 00000000
0090: 00000000 00000000 00000000 00000000
00a0: 00000000 00000000 00000000 00000000
00b0: 00000000 00000000 00000000 00000000
00c0: 00000000 00000000 00000000 00000000
00d0: 00000000 00000000 00000000 00000000
00e0: 00000000 00000000 00000000 00000000
00f0: 00000000 00000000 00000000 00000000
[END]
寄存器的值还是默认值,修改它:
~ # himm 0x120C0014 0x00001e04
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:168}cmdstr:himm
0x120C0014: 0x00001E00 –> 0x00001E04
[END]

再次echo测试:
~ # echo 123 > /dev/ttyAMA2
不成功,为什么呢?收发接反了!!!再次尝试,乱码,波特率不对,初始波特率是9600

UART1&UART2引脚复用寄存器
信号 UART1_TXD UART1_RXD UART2_TXD UART2_RXD
引脚 F17 F16 E1 D2
寄存器地址 0x100C000C 0x100C0010 0x120C0014 0x120C0010
寄存器初始值 0x1000 0x1000 0x1E00 0x1E00
寄存器设定值 0x1002 0x1002 0x1E04 0x1E04

hisi btools

1、编译
进入Hi3516EV200_SDK_V1.0.0.2/osdrv/tools/board/reg-tools-1.0.0
修改Makefile中的目标芯片的目标编译器,我的是3516EV300,对应编译器是himix200
ifndef CHIP
CHIP = hi3516ev300
endif

ifndef OSDRV_CROSS
OSDRV_CROSS ?= arm-himix200-linux
endif
保存直接make即可在bin文件夹下生成btools文件和几个软件连接
2、拷贝
把生成的btools文件拷贝到目标板,我放在sbin目录下了
3、软连接
以下是手工生成,太笨了,搞完才发现,可以自动
~ # ln -s /sbin/btools /sbin/himc
~ # ln -s /sbin/btools /sbin/himd
~ # ln -s /sbin/btools /sbin/himd.l
~ # ln -s /sbin/btools /sbin/himm
~ # ln -s /sbin/btools /sbin/hivd
~ # ln -s /sbin/btools /sbin/himdb
~ # ln -s /sbin/btools /sbin/hiddrs
~ # ln -s /sbin/btools /sbin/i2c_read
~ # ln -s /sbin/btools /sbin/i2c_write
~ # ln -s /sbin/btools /sbin/ssp_read
~ # ln -s /sbin/btools /sbin/ssp_write
自动生成命令:
进入/sbin目录,执行:btools -i
4、使用
himc : memory clear
himd : memory display (8bit)
himd.l : memory display (32bit)
himm : memory modify
hivd : video dump
himdb : video dump
hiddrs : ddr statistic
i2c_read : i2c device read
i2c_write : i2c device read
ssp_read : ssp device read
ssp_write : ssp device read

以下是修改E1引脚的复用功能为UART2_TXD
himd.l 0x120C0014
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:168}cmdstr:himd.l
====dump memory 0x120C0014====
0000: 00001e00 00001d00 00001400 00001d00
0010: 00000000 00000000 00000000 00000000
0020: 00000000 00000000 00000000 00000000
0030: 00000000 00000000 00000000 00000000
0040: 00000000 00000000 00000000 00000000
0050: 00000000 00000000 00000000 00000000
0060: 00000000 00000000 00000000 00000000
0070: 00000000 00000000 00000000 00000000
0080: 00000000 00000000 00000000 00000000
0090: 00000000 00000000 00000000 00000000
00a0: 00000000 00000000 00000000 00000000
00b0: 00000000 00000000 00000000 00000000
00c0: 00000000 00000000 00000000 00000000
00d0: 00000000 00000000 00000000 00000000
00e0: 00000000 00000000 00000000 00000000
00f0: 00000000 00000000 00000000 00000000
[END]

himm 0x120C0014 0x00001e04
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:168}cmdstr:himm
0x120C0014: 0x00001E00 –> 0x00001E04
[END]

HI3516EV300编译环境搭建(三)

单独编译U-boot
注意:发布包默认按照DMEB板的配置发布,如果客户单板和DEMB板不一致,需要根据客户自己的单板环境修改uboot表格才能使用,否则可能导致uboot无法启动或者其他问题。

待进入boot源代码目录后,执行以下操作
make ARCH=arm CROSS_COMPILE=arm-himix100-linux- hi3516ev300_defconfig
(emmc启动时执行如下操作:make ARCH=arm CROSS_COMPILE=arm-himix200-linux- hi3516ev300_emmc_defconfig)

make ARCH=arm CROSS_COMPILE=arm-himix100-linux- -j 20

make -C ../../../tools/pc/hi_gzip

cp ../../../tools/pc/hi_gzip/bin/gzip arch/arm/cpu/armv7/hi3516ev200/hw_compressed/ -rf

Windowns下进入到osdrv/tools/pc/uboot_tools/目录下打开对应单板的Excel文件,在main标签中点击”Generate reg bin file”按钮,生成reg_info.bin即为对应平台的表格文件。
从osdrv/tools/pc/uboot_tools目录拷贝reg_info.bin到boot源代码目录,重命名为.reg
cp ../../../tools/pc/uboot_tools/reg_info.bin .reg

make ARCH=arm CROSS_COMPILE=arm-himix200-linux- u-boot-z.bin

opensource/uboot/u-boot-2016.11下生成的u-boot-hi3516ev300.bin即为可用的u-boot镜像

HI3516EV300编译环境搭建(四)

单独编译内核

本文档简要说明将内核的补丁打到v4.9.37的linux kernel上。

1、从linux开源社区下载v4.9.37版本的内核:
1)进入网站:www.kernel.org
2)选择HTTP协议资源的https://www.kernel.org/pub/选项,进入子页面
3)选择linux/菜单项,进入子页面
4)选择kernel/菜单项,进入子页面
5)选择v4.x/菜单项,进入子页面
6)下载linux-4.9.37.tar.gz(或linux-4.9.37.tar.xz)

2、打补丁
1)将下载的 linux-4.9.37.tar.gz 存放到 osdrv的opensource/kernel目录中
2)在linux服务器中进入 osdrv 的根目录,执行如下命令:
cd opensource/kernel
tar -zxf linux-4.9.37.tar.gz
mv linux-4.9.37 linux-4.9.y
cd linux-4.9.y
patch -p1 < ../linux-4.9.37.patch cd ../ tar -czf linux-4.9.y.tgz linux-4.9.y cd ../../ 注意: 若下载的内核格式为linux-4.9.37.tar.xz, 第一步先用: xz -d linux-4.9.37.tar.xz 命令将linux-4.9.37.tar.xz解压为linux-4.9.37.tar。 第二步再用: tar -xvf linux-4.9.37.tar 解压linux-4.9.37.tar。 进入内核根目录 编译: 步骤 1. 手动拷贝.config 文件: cp arch/arm/configs/hi3516ev300_xxx_defconfig .config 步骤 2. 用户通过“make menuconfig” 进行内核配置: make ARCH=arm CROSS_COMPILE=arm-himix200-linux- menuconfig 步骤 3. 选择需要的模块。 步骤 4. 选择完毕后,保存并退出。 步骤 5. 编译内核,生成uImage镜像 make ARCH=arm CROSS_COMPILE=arm-himix200-linux- uImage -j20 此命令可能需要几分钟时间,编译完成,生成文件:arch/arm/boot/uImage,此文件可以烧写到目标板内核分区加载执行

Linux文件写权限与“删除权限”

linux下,文件有写权限却不能删除,可能是因为对文件的父目录没有写权限,因为目录是一种特殊的文件,它里面保存着目录下的文件列表,删除其下的文件,需要修改目录里面保存的信息。“一切皆文件”的思想又一次得到体现。

Once a month, the entire school meets to discuss how to homeworkhelper.net act positively and responsibly, to recite the pledge, to discuss how to be a successful student, and to honor students who have exhibited superior character traits.

我的Web开发之旅-入坑nginx

LAMP组合用了很长时间,最近实在受不了Apache了。本来就是加个虚拟主机,折腾好长时间也没搞定,网上找一堆教程不管用,去官网查文档依然没找到问题在哪,一堆活压在手里,心急如焚的我没了耐性,决定试试nginx。

其实慕名nginx很久了,一直安于LAMP的组合,没有着手去尝试,借此机会尝试一下。结果一试不要紧,在Apache那儿没有的耐性,在nginx这儿全磨出来了。原来nginx并不是我想象中的“傻白甜”。

一、Ubuntu apt-get安装

我的系统Ubuntu Server 16.04,安装前我先卸载了apache,安装nginx提示已安装,无需更新,难道是装系统的时候选了nginx安装包?不去计较,直接启动之。之后并不顺利,因为nginx配置文件和之前所使用的apache的写法简直不是一个套路,网上看了很多例子,终于能跑出静态页面了。然而打开php页面,浏览器直接给下载了下来,这实在是个“惊喜”。原来nginx不像apache,已经集成了cgi,所以需要额外安装,我直接安装了php-fpm。又在网上搜罗一堆博文,比葫芦画瓢终于见到了php的页面。到了虚拟主机,却又难住了,折腾许久,配置到最后发现if指令并不能工作,想到可能是版本的原因,那没有办法,只能源码编译安装了。

二、源码编译安装

wget http://nginx.org/download/nginx-1.13.8.tar.gz

tar zxvf nginx-1.13.8.tar.gz

./configure

make

make install

一路倒是顺利,安装目录是默认的/usr/local/nginx/,配置文件是conf/nginx.conf,可执行文件是sbin/nginx,打一个软连接:

ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx

三、命令行指令

nginx -h显示如下:

nginx version: nginx/1.13.8
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file

最常用的是重新输入配置文件,调试配置文件是很有用:

nginx -s reload

三、配置文件

最主要就是server这一部分了

server {
listen 80;
server_name www.oceiot.com oceiot.com;

set $root_path ‘/opt/www/public’; #定义root_path变量,设置默认的root路径
if ($uri ~ ^/phpmyadmin*) { #通过if指令判断要访问的子目录,并定义root路径
set $root_path ‘/opt/www’;
}
if ($uri ~ ^/public*) {
set $root_path ‘/opt/www’;
}

root $root_path; #使root_path生效

index index.php index.html index.htm;

try_files $uri $uri/ @rewrite; #找不到文件时重写uri

location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1; #重写uri到root_path下的index.php,并传递原始uri
}

#匹配php文件,包括上面rewrite后的uri,转到fast cgi,

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;

fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

#拒绝访问ht文件

location ~ /\.ht {
deny all;
}
}

The school posts a monthly newsletter to inform parents of upcoming events and other important information buyresearchpapers.net.

庸人不会因为错失机会而更平庸

英雄赶时世,时世造英雄。对于卓越的人来说,虽然他们的成功有赖于时机和境遇,但他们在机会到来之前已经做好了一切铺垫,一旦时机成熟,一跃成为人中龙凤;而平庸的人,过一天算一天,根本不想明天会不会有进步,后天的会不会有新面貌,这样的人,哪怕错失再多的机会,也还是那个他,自然也不会变得更平庸。

做人,定位很重要。定位高的人,对机会报以积极的态度,主动抓住机会,勇于争取机会,敏锐发掘机会,仿佛每一次机会,都有可能改变自己的命运;而定位低的人,安于现状,不思进取,“淡泊机会”,视机会如粪土,即使机会摆在面前,也懒于伸手。平庸之人总会说,错过了那些机会,我不也过得好好的吗?是啊,你对自己要求如此之低,你所谓的“好好的”,已经是不能再差的“好好的”,更何况,当今的社会,所有事物都在快速发变化着,这样的环境下,不进就是一种退。

庸人,之所以为庸人,不是因为能力低下,不是因为

The principal of this title I school, buy a research paper for college cheap where 66% of the students qualify for the free or reduced lunch program, is ms.