Bovey's Blog

点滴


  • 首页

  • 归档

  • 标签

linux程序安装和arm移植的一点理解

发表于 2019-08-09

之前的理解

知道sudo apt-get install ***可以安装一些工具、软件。但是实际上对安装过程的理解并不是很懂。
后来会用过make config, make install之类来安装。了解到源码的编译安装过程。 但是如何装到内核文件系统还是不太了解

新的领悟

echo $PATH这个命令是经常会用的,还用过env查看所有环境变量。但是并不知道这些变量哪里来的。 刚才忽然想到应该是这样,make的时候完成对源文件的编译,make install的时候会进行编译输出文件的复制和环境变量的配置。 所以应用文件移植到arm的过程就是用arm-linux-gnueai-*进行编译,安装到指定文件夹, 然后把文件夹复制到arm内核文件系统。再把相关路径添加到PATH环境变量里就应该可以了。

  1. 下载安装包源文件
  2. 用arm编译工具编译安装包
  3. 把软件包安装到指定文件夹下
  4. 把输出文件夹内的文件复制到arm文件系统
  5. 修改arm文件系统的环境变量etc/profile

验证结果

//todo

150G的C盘又满了

发表于 2019-06-20

背景

C盘100G满的时候扩容到了150G,如今又提示不到13G了。。。

不能忍

眼睁睁看着C盘变大的时候,尝试过很多种廋身办法都没啥效果。

绝地反击

后来发现在C盘取消所有文件隐藏的条件下,选中所有文件,查看大小是100G,这里消失的几十G哪里去了。。。 然后就想着如何查看文件夹大小,接着就找到了工具wiztree,这个是好东西,软件很小,但是能几秒内统计100G的文件大小,并用色块表示文件大小。这样很容易就定位到了一些好几G的大文件夹,找到没用的删除之。 其中有1个文件是N卡驱动缓存文件,5-6个G,使用工具DriverStoreExplorer.v0.10.39完成扫码驱动备份,并删除老版本的驱动

C:\windows\softwaredistribution过大处理

需要以管理员身份启动cmd

1
2
3
4
5
6
    Start>Run
    type cmd and press enter
    type net stop wuauserv and press enter
    type rename c:\windows\SoftwareDistribution softwaredistribution.old and press enter
    type net start wuauserv and press enter
    type exit and press enter

Hiberfil.sys很大

Hiberfil.sys 是 Windows 休眠功能(Windows Hibernation)将内存数据与会话保存至硬盘、 以便计算机断电重新启动后可以快速恢复会话所需的内存镜像文件。在早期版本的 Windows 中,Hiberfil.sys 文件的大小等同于物理内存大小;而在 Windows 7 中,Hiberfil.sys 可以在物理内存大小的 50%-100% 的范围自行调整。 因此, Windows 7 的 Hiberfil.sys 大小不一定等同于物理内存大小。 需要以管理员身份启动cmd

1
2
3
cmd
powercfg -h off //关系休眠,该文件可删除
powercfg -h on //如果需要可执行该命令,再次启动休眠

惨痛的教训

C:\Program Files\目录下有uninstall.exe文件,还有一些数据库文件,数据库相关的文件日期是14年的,可能是什么时候装软件选择的不对没有放到文件夹下。想用uninstall删除,结果悲催了。这个文件居然开始删除adobe和autocad,赶紧任务管理杀掉进程。后来分析uninstall是用来删除文件夹下其他文件的,所以…如果放任不管,我可能就真的悲催了。 就这样重装了adobe,autocaad,7zip,git等问题解决。

ubuntu mplayer no voice

发表于 2019-06-10

安装

ubuntu环境18.04下

1
2
sudo apt-get install mplayer
sudo apt-get remove mplayer

播放MP3

在mp3文件夹下执行

1
mplayer xxx.mp3

执行播放后无声音。发现Ubuntu下设置声音为静音。。。。打开后输出声音正常

190427-ubuntu-qt-ide

发表于 2019-04-27

参考

Ubuntu–搭建QT开发环境

各种装

1
2
3
4
sudo apt-get install qt4-dev-tools		//QT资源包
sudo apt-get install qt4-qtconfig //配置工具
//sudo apt-get install qt-demos //官方案例源代码
//sudo apt-get install qtcreator //IDE

安装过程出现依赖项问题,解决办法:

1
sudo aptitude install qtcreator

安装过程遇到libclang-3.6 libobjc-5-dev libobjc4没有安装,输入n,切换解决方案。部分库版本过高,选择降版本处理。

安装完成后执行

1
2
3
qmake -v
# QMake version 2.0.1a
Using Qt version 4.8.7 in /usr/lib/x86_64-linux-gnu

编译工具

  1. 下载poky 下载路径:https://pan.baidu.com/s/11WdTVIuiZNdrW1f5QjYAQA 提取码:9zhv
  2. 安装: sh xx.sh
  3. 配置环境变量,在/opt/poky/1.4.3路径下执行 source enviroment-setup-arm5te-poky-linux-gnuabi

## fatal error: alsa/asoundlib.h: No such file or directory

190424-linux-dev-esp32

发表于 2019-04-24

开发环境

安装Linux下的软件需求

1
sudo apt-get install gcc git wget make libncurses-dev flex bison gperf python python-pip python-setuptools python-serial python-cryptography python-future python-pyparsing python-pyelftools

linux环境设置

下载地址:

1
2
3
mkdir -p /home/username/esp
cd /home/username/esp
tar -xzf /home/username/Downloads/xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz

2.设置环境变量PATH,以便能搜索到我们的编译工具链 在/home/username/.profile中添加

1
export PATH=$PATH:/home/username/esp/xtensa-esp32-elf/bin

具体操作: /usrname路径下

.profile```, 然后在文件尾部输入`o`,写入上面内容,输入`wq`退出。
1
2
```
source .profile

执行echo $PATH查看环境变量结果

git clone SDK ESP-IDF

在esp目录下

1
2
git clone --recursive http://github.com/espressif/esp-idf.git
git submodule add https://github.com/tuanpmt/espmqtt.git components/espmqtt

…等一会 如果没有安装git

1
sudo apt install git

环境变量

1
2
echo "export IDF_PATH=~/esp/esp-idf" >> ~/.bashrc
source ~/.bashrc

编译helloworld

1
2
cd examples/get-started/hello_world/
make

烧写固件

识别到ttyUSB0设备后执行命令

1
2
sudo chmod 777 /dev/ttyUSB0
make flash monitor

提示recipe for target 'flash' failed,输入sudo chmod 777 /dev/ttyUSB0即可

ESP-TOUCH

https://github.com/EspressifApp/ESP-TOUCHForAndroid

bug

  1. /esp/esp-idf/components/espmqtt/目录下执行mv mqtt_client.c mqtt_client.c.bak
  2. /esp/esp-idf/components/espmqtt/include目录下执行mv mqtt_client.h mqtt_client.h.bak

190401-tr_printer_debug

发表于 2019-04-01

2A版本打印机调试记录

打印机接口调试

版本变更:更换电平转换芯片,更换数据输出接口使layout更容易。 修改代码后发现不能正常打印测试内容。经过各种验证得出如下结论:

  • 可打印整行直线,即DAT线长高
  • CLK,DAT,LATCH,DST信号波形良好无畸变

尝试上拉、下拉无果

修改GPIO输出速度为High 无果

示波器测试各信号线波形良好。各种测试无果。

最后在DAT,CLK,LATCH信号线上串联47ohm电阻,问题解决.

  1. DAT+CLK+LATCH OK
  2. ONLY DAT NOT OK
  3. DAT+CLK OK
  4. ONLY CLK OK
  5. CLK串联电阻替换为对地并联电容,问题解决

因为所用示波器采样率低,测试为发现波形明显异常。 根据并联电容解决问题,分析CLK沿变太快导致接收异常。

190324-ubuntu 16 for imx6,7,8

发表于 2019-03-24

boot from sd

参考 SD 卡启动是开发板系统启动方式的一种。 SD 系统启动卡共有 FAT32、 EXT3 两个格式分区,还包含 RAW 格式的无名分区。其中 FAT32 格式分区在 Windows 系统下可见,EXT3 格式分区在 Windows 系统下不可见,两分区在 Linux 系统下均可见。无名分区在Windows 和 Linux 操作系统下均不可见。 无名分区存放 u-boot.ais, FAT32 格式分区存放内核文件 uImage、系统启动脚本等文件, EXT3 格式分区存放文件系统。

如何做个SD卡启动卡

step1 安装mkimage,搭建环境

1
sudo apt-get install uboot-mkimage

提示

1
2
3
4
5
6
7
8
9
10
11
12
13
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package uboot-image
root@ubuntu:/# apt-get install uboot-mkimage
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package uboot-mkimage is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
u-boot-tools:i386 u-boot-tools

重新输入命令

1
sudo apt-get install u-boot-tools

安装好后命令行输入mkimage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Usage: mkimage -l image
-l ==> list image header information
mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
-A ==> set architecture to 'arch'
-O ==> set operating system to 'os'
-T ==> set image type to 'type'
-C ==> set compression type 'comp'
-a ==> set load address to 'addr' (hex)
-e ==> set entry point to 'ep' (hex)
-n ==> set image name to 'name'
-d ==> use image data from 'datafile'
-x ==> set XIP (execute in place)
mkimage [-D dtc_options] [-f fit-image.its|-F] fit-image
-D => set all options for device tree compiler
-f => input filename for FIT source
Signing / verified boot not supported (CONFIG_FIT_SIGNATURE undefined)
mkimage -V ==> print version information and exit
Use -T to see a list of available image types

step2 SD卡启动脚本制作

  • 将 SD 卡格式化成无名分区( RAW 格式)、 boot 分区( FAT32 格式)和 rootfs分区( EXT3 格式)。
  • 拷贝镜像所在目录相关文件到 SD 卡对应分区。
  • 在 boot 分区生成 SD 卡启动脚本源文件和 SD 卡启动脚本镜像。

step3 把镜像等文件复制到sd卡上

190321-cadence note

发表于 2019-03-21

原理图中画三角形

选择Place->Poliline,或者快捷键”Y”,启动画多边形命令,默认情况是画直角多边形的,按下shift可画任意角度拐角,这样就可以画三角形了。

allegro局部缩放

Manufacture->draft->Create detail 局部缩放

190320 linux cmd

发表于 2019-03-20

查看存储空间使用情况

1
2
3
4
//查看当前系统磁盘使用空间
df -h
//查看当前目录文件占用空间大小
du -sh *

运行效果如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@tianRong:/usr# du -sh *
5.7M bin
112.0K etc
128.5M lib
0 local
60.0K regdefault
1.4M sbin
6.3M share

root@tianRong:/usr# df -h
Filesystem Size Used Available Use% Mounted on
ubi0:rootfs 104.6M 98.6M 1.3M 99% /
devtmpfs 60.4M 4.0K 60.4M 0% /dev
tmpfs 60.6M 80.0K 60.5M 0% /var/volatile
tmpfs 60.6M 0 60.6M 0% /media/ram
tmpfs 60.6M 244.0K 60.4M 0% /tmp
ubi0_1 107.9M 24.0K 103.1M 0% /mnt/user

重新加载文件系统

1
mount -o remount -rw /

Linux 文件权限 变成制度 readonly 解决方法 文件系统加载为只读

-n -o remount,rolink
1
2
3
4
5
6
7
8
9
10
修改为```mount -n -o remount, rw /```即为读写模式加载


## su,sudo,退出
终端使用sudo可实现,使用su可进入root把$变成#
退出:ctrl+D,exit,logout

## ls -Sl或-lS 按大小排序

## 遍历当前文件夹中所有文件夹内文件,输出md5到指定文件夹

find ./ ! -name ‘checksum’ -prune -type f -print0 | xargs -0 md5sum > ./checksum

1
## 打包

tar -zcvf rootfs.tar.gz ./rootfs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
打包过程:
1. 把当前可用的最新文件系统复制到Linux下
2. 把调试中修改过的usr,opt,etc文件夹打包,并复制到Linux下
3. 把修改后的3个文件夹替换,替换后遍历所有文件并做MD5校验
4. 把新的文件系统打包

## 删除文件夹
rm -rf * //删除文件下所有文件,包含子文件夹

## 环境变量删除
export -n

## 查看文件被哪个进程占用
lsof

## QT命令行编译
执行qmake xxx.pro生产makefile,执行make完成编译


## 声音播放,音量调节
aplay ***.mav
alsamixer
aplay -l 可查看声卡信息
aplay -D plughw:0,0 xxx.wav


## ubuntu下rpm包解压缩
rpm2cpio ../alsa-lib-dev-1.1.0-r0.armv5e.rpm | cpio -idv
批量使用
for name in *.rpm; do rpm2cpio $name | cpio -idv; done

## sh文件安装
sh xx.sh

## 脚本死循环

cnt=1; while : do echo $cnt; let cnt+=1; xxx sleep 3 done

1
2

## 脚本升级

1
2

## 脚本MD5

sudo rm rootfs.tar.gz sudo rm checksum sudo find -type f | xargs md5sum >/tmp/checksum sudo cp /tmp/checksum checksum sudo tar cvzf rootfs.tar.gz * sudo chmod -R 777 rootfs.tar.gz

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
`md5sum -c checksum`校验结果,其中checksum为校验结果存放位置


## 解压
.tar
解包:tar xvf FileName.tar
打包:tar cvf FileName.tar DirName
(注:tar是打包,不是压缩!)
---------------------------------------------
.gz
解压1:gunzip FileName.gz
解压2:gzip -d FileName.gz
压缩:gzip FileName
.tar.gz 和 .tgz
解压:tar zxvf FileName.tar.gz
压缩:tar zcvf FileName.tar.gz DirName
---------------------------------------------
.bz2
解压1:bzip2 -d FileName.bz2
解压2:bunzip2 FileName.bz2
压缩: bzip2 -z FileName
.tar.bz2
解压:tar jxvf FileName.tar.bz2
压缩:tar jcvf FileName.tar.bz2 DirName
---------------------------------------------
.bz
解压1:bzip2 -d FileName.bz
解压2:bunzip2 FileName.bz
压缩:未知
.tar.bz
解压:tar jxvf FileName.tar.bz
压缩:未知
---------------------------------------------
.Z
解压:uncompress FileName.Z
压缩:compress FileName
.tar.Z
解压:tar Zxvf FileName.tar.Z
压缩:tar Zcvf FileName.tar.Z DirName
---------------------------------------------
.zip
解压:unzip FileName.zip
压缩:zip FileName.zip DirName
---------------------------------------------
.rar
解压:rar x FileName.rar
压缩:rar a FileName.rar DirName
rar请到:
http://www.rarsoft.com/download.htm
下载!
解压后请将rar_static拷贝到/usr/bin目录(其他由$PATH环境变量指定的目录也能):
[root@www2 tmp]# cp rar_static /usr/bin/rar
---------------------------------------------
.lha
解压:lha -e FileName.lha
压缩:lha -a FileName.lha FileName
lha请到:
http://www.infor.kanazawa-it.ac.jp/~ishii/lhaunix/
下载!
>解压后请将lha拷贝到/usr/bin目录(其他由$PATH环境变量指定的目录也能):
[root@www2 tmp]# cp lha /usr/bin/
---------------------------------------------
.rpm
解包:rpm2cpio FileName.rpm | cpio -div
---------------------------------------------
.deb
解包:ar p FileName.deb data.tar.gz | tar zxf -
---------------------------------------------
.tar .tgz .tar.gz .tar.Z
.tar.bz .tar.bz2 .zip .cpio .rpm .deb .slp .arj .rar .ace .lha .lzh
.lzx .lzs .arc .sda .sfx .lnx .zoo .cab .kar .cpt .pit .sit .sea
解压:sEx x FileName.*
压缩:sEx a FileName.* FileName
sEx只是调用相关程式,本身并无压缩、解压功能,请注意!
sEx请到:
http://sourceforge.net/projects/sex
下载!
解压后请将sEx拷贝到/usr/bin目录(其他由$PATH环境变量指定的目录也能):
[root@www2 tmp]# cp sEx /usr/bin/


## arm交叉编译器gnueabi、none-eabi、arm-eabi、gnueabihf、gnueabi区别
命名规则
交叉编译工具链的命名规则为:arch [-vendor] [-os] [-(gnu)eabi]

arch – 体系架构,如ARM,MIPS
vendor – 工具链提供商
os – 目标操作系统
eabi – 嵌入式应用二进制接口(Embedded Application Binary Interface)
根据对操作系统的支持与否,ARM GCC可分为支持和不支持操作系统,如

arm-none-eabi:这个是没有操作系统的,自然不可能支持那些跟操作系统关系密切的函数,比如fork(2)。他使用的是newlib这个专用于嵌入式系统的C库。
arm-none-linux-eabi:用于Linux的,使用Glibc


实例
1、arm-none-eabi-gcc
(ARM architecture,no vendor,not target an operating system,complies with the ARM EABI)
用于编译 ARM 架构的裸机系统(包括 ARM Linux 的 boot、kernel,不适用编译 Linux 应用 Application),一般适合 ARM7、Cortex-M 和 Cortex-R 内核的使用,所以不支持那些跟操作系统关系密切的函数,比如fork(2),他使用的是 newlib 这个专用于嵌入式系统的C库。

2、arm-none-linux-gnueabi-gcc
(ARM architecture, no vendor, creates binaries that run on the Linux operating system, and uses the GNU EABI)

主要用于基于ARM架构的Linux系统,可用于编译 ARM 架构的 u-boot、Linux内核、linux应用等。arm-none-linux-gnueabi基于GCC,使用Glibc库,经过 Codesourcery 公司优化过推出的编译器。arm-none-linux-gnueabi-xxx 交叉编译工具的浮点运算非常优秀。一般ARM9、ARM11、Cortex-A 内核,带有 Linux 操作系统的会用到。

3、arm-eabi-gcc
Android ARM 编译器。

4、armcc
ARM 公司推出的编译工具,功能和 arm-none-eabi 类似,可以编译裸机程序(u-boot、kernel),但是不能编译 Linux 应用程序。armcc一般和ARM一起,Keil MDK、ADS、RVDS和DS-5中的编译器都是armcc,所以 armcc 编译器都是收费的(爱国版除外,呵呵~~)。

5、arm-none-uclinuxeabi-gcc 和 arm-none-symbianelf-gcc
arm-none-uclinuxeabi 用于uCLinux,使用Glibc。

arm-none-symbianelf 用于symbian,没用过,不知道C库是什么 。


## 缺少包查找
* 如果PC上可以执行到板子上不能执行,那么说明板子上的文件系统里缺少某个包,并且板子上一般会提醒缺少哪个包的。
* 如何在PC上找到对你应的包呢?apt-file search
* sudo apt-get install apt-file
* sudo apt-file update
* apt-file search *.so.1
* 例如:apt-file search libjpeg.so.8

libjpeg-turbo8: /usr/lib/x86_64-linux-gnu/libjpeg.so.8
libjpeg-turbo8: /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
```
* 右边的是匹配你的库,左边的是你查的库所在的包,所以需要的包是libjpeg-turbo8
* 判断库是否能用:objdump -a  *.so,看库是64位的还是32位的,是否与目标板一致

如何快速下载ubuntu

由于官网服务器在国外,下载速度奇慢,所以我们可以利用阿里云镜像下载ubuntu ubuntu 14.04: http://mirrors.aliyun.com/ubuntu-releases/14.04/ ubuntu 16.04: http://mirrors.aliyun.com/ubuntu-releases/16.04/ ubuntu 18.04: http://mirrors.aliyun.com/ubuntu-releases/18.04/ 没错,只要市面上存在的版本,阿里云镜像基本都有,下载速度可以达到3M/s

编译结果各字段含义

发表于 2019-01-30

参考

1
2
  text       data        bss        dec        hex    filename
0x1408 0x18 0x81c 7228 1c3c size.elf

text ‘text’ is what ends up in FLASH memory. I can show this with adding

data ‘data’ is used for initialized data. This is best explained with the following (global/extern) variable:

bss The ‘bss’ contains all the uninitalized data.

💡 bss (or .bss, or BSS) is the abbreviation for ‘Block Started by Symbol’ by an old assembler (see this link).

dec The ‘dec’ (as a decimal number) is the sum of text, data and bss:

1
dec = text + data + bss

Size – GNU Utility The size (or printsize) GNU utility has more options:

Summary I hope I have sorted out things in a correct way. The way how the initialized data is reported might be confusing. But with the right knowledge (and .map file in mind), things get much clearer:

‘text’ is my code, vector table plus constants.

‘data’ is for initialized variables, and it counts for RAM and FLASH. The linker allocates the data in FLASH which then is copied from ROM to RAM in the startup code.

‘bss’ is for the uninitialized data in RAM which is initialized with zero in the startup code.

12…5
xu.bovey

xu.bovey

点点 - 滴滴

49 日志
18 分类
27 标签
RSS
© 2019 xu.bovey
由 Hexo 强力驱动
主题 - NexT.Pisces