15AH, San Francisco

California, United States.

Send Your Mail At:

tianyingkejishe@sina.cn

Working Hours

Mon-Sat: 9.30am To 7.00pm

归档标题

Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et dolore feugait.

月度归档 7月 30, 2022

【NMEA】校验和计算

uint8_t GPS_Check(uint8_t *p)
{
        uint8_t checksum=0;
        uint8_t i=0;


        while(p[i] !=0)
        {
                checksum ^=p[i];
                i++;
        }
        return checksum;
}

【NXP】NXP(Freescale) QorIQ CodeWarrior TAP使用

通讯方式有两种:

一、USB通讯

这个相对简单,但速率低。配置流程如下,配置完保存即可。

二、网口通讯

配置复杂,速率高。先连上USB,配置流程如下:

连接后,配置IP

Push enter to start console.

                  ####
               ##########
            ##########  ....          Freescale Semiconductor Inc.
               ####  ..........       Copyright (c) 2015
                  ..........  ####    All Rights Reserved
                     ....  ##########
                        ##########    Codewarrior TAP Firmware
                    ....   ####       Boot Loader Version 1.0.1
                 ..........             built Mon Aug 26 18:55:20 UTC 2013
              ..........  ####        OS Version 1.0.4
          ####   ....  ##########       built Thu Apr 23 22:28:59 UTC 2015
       ##########   ##########
    ##########  ....   ####           Main Board: CodeWarrior TAP (3.3V)
       ####  ..........               Probe Tip:  Power Architecture JTAG/COP
          ..........
      ####   ....
   ##########                         Note: This product uses open-source
##########                            components.  See "help license"
   ####                               for details.

Network not configured - defaulting to DHCP
core> help
Help is available for these commands:
  arp           ARP table commands.
  ccs           Display/manage CCS firmware
  gdbproxy      Display/manage gdbproxy firmware
  help          Get help on commands
  host          Host table commands
  license       Displays open-source license details
  netparam      Show/set nonvolatile networking parameters.
  netstat       Display network protocol statistics.
  ping          Test if host is alive.
  reset         Reboot this device.
  route         Route table commands.
  tgreset       Reset target
  tgtty         Get/set tty settings for target serial
  who           List any open connections.
core> help netparam
Usage: netparam [subcommand <subcommand options>]

This command displays or sets nonvolatile networking
parameters. If called with no subcommand, it displays all
parameters.  When called with one of the subcommands listed
below, it changes the parameters associated with that command.
Note that when changed, some parameters will not be activated
until the unit is rebooted.
Use "netparam <subcommand> --help" for help on a specific 
subcommand.

Netparam recognizes the following subcommands:
         add_host               Add static host
         add_route              Add static route
         bootconfig             Boot method selection
         delete_host            Delete static host
         delete_route           Delete static route
         static_ip_address      Specify static IP address
         static_dns_server      Specify DNS server address

设置静态IP,命令会阻塞10s,这个时候CodeWarrior TAP的RX/TX灯变为绿色,

core> netparam static_ip_address 192.168.6.223 # wait for 10s
core> netparam add_route 192.168.6.254 gateway_ip 1 # hop_cnt=1
core> netparam bootconfig static:cw-tap0
Netmask defaults to 255.255.255.0
Using dynamic IP address 192.168.6.223                                          
core> ping 192.168.6.6
PING 192.168.6.6 (192.168.6.6): 56 data bytes
64 bytes from 192.168.6.6: seq=0 ttl=128 time=0.917 ms
64 bytes from 192.168.6.6: seq=1 ttl=128 time=0.640 ms

--- 192.168.6.6 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.640/0.778/0.917 ms

跨网段设置路由,有警告但是设置成功。

core> netparam add_route 192.168.12.0 192.168.6.254 1
Netmask defaults to 255.255.255.0
gateway_ip: Unknown host
route: netmask doesn't match route address
Usage: route [-nNvee] [-FC] [<AF>]           List kernel routing tables
       route [-v] [-FC] {add|del|flush} ...  Modify routing table for AF.

       route {-h|--help} [<AF>]              Detailed usage syntax for specified AF.
       route {-V|--version}                  Display version/author and exit.

        -v, --verbose            be verbose
        -n, --numeric            don't resolve names
        -e, --extend             display other/more information
        -F, --fib                display Forwarding Information Base (default)
        -C, --cache              display routing cache instead of FIB

  <AF>=Use '-A <af>' or '--<af>'; default: inet
  List of possible address families (which support routing):
    inet (DARPA Internet) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) 
    ipx (Novell IPX) ddp (Appletalk DDP) x25 (CCITT X.25) 
SIOCADDRT: File exists
core> ping 192.168.12.16
PING 192.168.12.16 (192.168.12.16): 56 data bytes
64 bytes from 192.168.12.16: seq=0 ttl=127 time=2.608 ms
64 bytes from 192.168.12.16: seq=1 ttl=127 time=0.526 ms
64 bytes from 192.168.12.16: seq=2 ttl=127 time=0.585 ms

--- 192.168.12.16 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.526/1.239/2.608 ms

查看路由表

core> netparam add_route 192.168.16.0 192.168.6.254 1
Netmask defaults to 255.255.255.0
gateway_ip: Unknown host
route: netmask doesn't match route address
Usage: route [-nNvee] [-FC] [<AF>]           List kernel routing tables
       route [-v] [-FC] {add|del|flush} ...  Modify routing table for AF.

       route {-h|--help} [<AF>]              Detailed usage syntax for specified AF.
       route {-V|--version}                  Display version/author and exit.

        -v, --verbose            be verbose
        -n, --numeric            don't resolve names
        -e, --extend             display other/more information
        -F, --fib                display Forwarding Information Base (default)
        -C, --cache              display routing cache instead of FIB

  <AF>=Use '-A <af>' or '--<af>'; default: inet
  List of possible address families (which support routing):
    inet (DARPA Internet) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) 
    ipx (Novell IPX) ddp (Appletalk DDP) x25 (CCITT X.25) 
SIOCADDRT: File exists
SIOCADDRT: File exists
core> netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
127.0.0.0       *               255.0.0.0       U         0 0          0 lo
169.254.0.0     *               255.255.0.0     U         0 0          0 usb0
192.168.6.0     *               255.255.255.0   U         0 0          0 eth0
192.168.6.0     192.168.6.254   255.255.255.0   UG        0 0          0 eth0
192.168.12.0    192.168.6.254   255.255.255.0   UG        0 0          0 eth0
192.168.16.0    192.168.6.254   255.255.255.0   UG        0 0          0 eth0

重启,需要把secureCRT的串口disconnect

core> reset
Close this configuration console to reboot...
(hit Ctrl+c to abort)

再重新打开,输入回车,和之前显示不一样了

Push enter to start console.

                  ####
               ##########
            ##########  ....          Freescale Semiconductor Inc.
               ####  ..........       Copyright (c) 2015
                  ..........  ####    All Rights Reserved
                     ....  ##########
                        ##########    Codewarrior TAP Firmware
                    ....   ####       Boot Loader Version 1.0.1
                 ..........             built Mon Aug 26 18:55:20 UTC 2013
              ..........  ####        OS Version 1.0.4
          ####   ....  ##########       built Thu Apr 23 22:28:59 UTC 2015
       ##########   ##########
    ##########  ....   ####           Main Board: CodeWarrior TAP (3.3V)
       ####  ..........               Probe Tip:  Power Architecture JTAG/COP
          ..........
      ####   ....
   ##########                         Note: This product uses open-source
##########                            components.  See "help license"
   ####                               for details.

Network configuration is static:cw-tap0
Using static IP address 192.168.6.223

这个时候,断开USB,采用USB供电,方可使用网络来连接,下载器自带了一个串口,设置串口参数,查看串口设置

core> help tgtty
Usage: tgtty [<options>]

Use this command to get and set target serial settings.  Without
options, this command displays current settings.  The following
options are accepted:
[reset]                                       -- terminates any open connections
[default]                                     -- set default settings
[<9600 | 19200 | 38400 | 57600 | 115200>]     -- baud rate
[<data5 | data6 | data7 | data8>]             -- data bits
[<stop1 | stop2>]                             -- stop bits
[<noparity | oddparity | evenparity>]         -- parity
[<rtscts | nortscts | rxtx>]                  -- hardware flow control
[<noxon | xon>]                               -- XON/XOFF flow control
[<echo | noecho>]                             -- whether the target echos

The default settings are:
9600 data8 stop1 noparity nortscts noxon echo
core> tgtty
115200 data8 stop1 noparity nortscts noxon echo

设置参数,会自动保存

core> tgtty 115200 data8 stop1 noparity nortscts noxon echo

恢复默认

core> tgtty default

使用这个串口,telnet登录下载器的1082端口。

【OPENWRT】 RT5350 SPI I2C驱动简单说明

openwrt中已经支持 RT5350 的SPI I2C等驱动。

一、选择SPI、I2C 功能

-> Kernel modules
  -> SPI Support
  -> I2C support

二、修改设备树

vi target/linux/ramips/dts/rt5350.dtsi

 i2c@900 {
                        compatible = "link,rt5350-i2c", "ralink,rt2880-i2c";
                        reg = <0x900 0x100>;

                        resets = <&rstctrl 16>;
                        reset-names = "i2c";

                        #address-cells = <1>;
                        #size-cells = <0>;

                        pinctrl-names = "default";
                        pinctrl-0 = <&i2c_pins>;

                        status = "disabled";
                };

                spi@b00 {
                        compatible = "ralink,rt5350-spi";
                        reg = <0xb00 0x100>;

                        resets = <&rstctrl 18>;
                        reset-names = "spi";

                        #address-cells = <1>;
                        #size-cells = <1>;

                        pinctrl-names = "default";
                        pinctrl-0 = <&spi_pins &spi_cs1>;

                        status = "disabled";
                };

配置文件默认是不启用 SPI I2C 的。我们需要把 status = “disabled”; 改为 status = “okay”;对于 I2C,我们还要修改模板设备树文件:

pinctrl {
                state_default: pinctrl0 {
                        gpio {
                                ralink,group = "i2c", "jtag", "rgmii", "mdio", "uartf";
                                ralink,function = "gpio";
                        };
                };
        };

复用功能”i2c”,”jtag”, “rgmii”, “mdio”, “uartf” 等默认都复用为 gpio 口,要启用 I2C,需要去掉 i2c。同样,我们还需要启用 uartf。所有,修改为:

pinctrl {
                state_default: pinctrl0 {
                        gpio {
                                ralink,group =  "jtag", "rgmii", "mdio";
                                ralink,function = "gpio";
                        };
                };
        };

【GOLang】golang cgo交叉编译 linux arm64

一、交叉编译工具链安装

二、设置环境变量

CGO_ENABLED=1: 因为我们的程序使用到了Cgo,因此编译打开Cgo标志,默认情况是关闭的。
CC=aarch64-linux-gnu-gcc:指定CC也就是gcc编译命令使用交叉编译工具 aarch64-linux-gnu-gcc,也就是我们之前安装的交叉编译工具。
GOOS=linux:编译目标系统为Linux
GOARCH=arm64:编译目标的指令集架构为 64位 arm 架构
-ldflags ‘-s -w’:这个选项是为了移除编译后的程序的编译调试信息,减少可执行文件的体积。
–extldflags “-static -fpic”:静态编译,也就是会把使用到的动态库,静态链接到程序中,该指令存在时候可能会有warning提示,这是因为有些库文件是不能被静态链接的,gcc 编译器不支持 参考 [6]。

【NXP】Lx2160的uart1口不好使

查看板卡设备存在

root@localhost:~# ls /dev/ttyAMA*
ttyAMA0  ttyAMA1 。

官方哪里又要了一个内和设备树补丁。这个补丁很重要,应该是更改了pl011的驱动匹配。

diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
index 2fe86aca32da..e316bb09f7a1 100644
--- a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
@@ -894,26 +894,29 @@
 		};
 
 		uart1: serial@21d0000 {
-			compatible = "arm,sbsa-uart","arm,pl011";
+			compatible = "arm,pl011", "arm,primecell";
 			reg = <0x0 0x21d0000 0x0 0x1000>;
 			interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
-			current-speed = <115200>;
+			clocks = <&clockgen 4 7>, <&clockgen 4 7>;
+			clock-names = "uart", "apb_pclk";
 			status = "disabled";
 		};
 
 		uart2: serial@21e0000 {
-			compatible = "arm,sbsa-uart","arm,pl011";
+			compatible = "arm,pl011", "arm,primecell";
 			reg = <0x0 0x21e0000 0x0 0x1000>;
 			interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;
-			current-speed = <115200>;
+			clocks = <&clockgen 4 7>, <&clockgen 4 7>;
+			clock-names = "uart", "apb_pclk";
 			status = "disabled";
 		};
 
 		uart3: serial@21f0000 {
-			compatible = "arm,sbsa-uart","arm,pl011";
+			compatible = "arm,pl011", "arm,primecell";
 			reg = <0x0 0x21f0000 0x0 0x1000>;
 			interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
-			current-speed = <115200>;
+			clocks = <&clockgen 4 7>, <&clockgen 4 7>;
+			clock-names = "uart", "apb_pclk";
 			status = "disabled";
 		};
 
-- 

【Centos】WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

一、问题描述

在部署OpenStack环境的时候,配置的静态IP是192.168.5.1,删除了这台虚拟机.

重新创建一个虚拟机,IP配置也配置为192.168.5.1.

使用本机连接 ssh  192.168.5.1出现如下报错

报错的大概意思是192.168.5.1的ECDSA主机密钥已更改,并且您已请求严格检查,远程主机发送的ECDSA密钥指纹信息是和本机的密钥指纹信息不一致

ssh链接的时候首先会验证公钥,如果公钥不对,那么就会报错,

二、解决办法

我们需要删除本机 ~/.ssh/known_hosts文件的192.168.5.1[需要远程的主机IP] 公钥信息

【openwrt】Openwrt配置串口登录密码

Openwrt15.05配置串口登录密码

一、修改busybox

make menuconfig选择

Base system —>
	<*> busybox ……
		[*] Customize busybox option
			Login/Password Management Utilities —>
				[*] getty
				[*] login (NEW)

二、修改启动脚本package/base-files/files/etc/inittab

vim inittab

::askconsole:/bin/ash --login

改为

::askconsole:/bin/login

三、修改 vi target/linux/ramips/base-files/etc/inittab

::askconsole:/bin/ash --login

改为

::askconsole:/bin/login

重新编译。

Openwrt18.06配置串口登录密码

一、修改busybox

make menuconfig选择

Base system —>
	<*> busybox ……
		[*] Customize busybox option
			Login/Password Management Utilities —>
				[*] getty
				[*] login (NEW)

二、修改启动脚本package/base-files/files/usr/libexec

vim login.sh

[ "$(uci -q get system.@system[0].ttylogin)" = 1 ] || exec /bin/ash --login

改为

[ "$(uci -q get system.@system[0].ttylogin)" = 1 ] || exec /bin/login

重新编译。