使用 qemu 调试 linux kernel

在 Ubuntu 中build kernel 参考如下: [Ref] https://wiki.ubuntu.com/KernelTeam/GitKernelBuild  可以直接在宿主机调试kernel, 但是当发生崩溃之后,工作环境又要重新配置。  所以考虑用 qemu,因为它有个option: -kernel, 可以直接引导kernel。比 VirtualBox 等虚拟机更快速更方便。 尝试使用 qemu 直接启动主机上的kernel  $ sudo qemu-system-x86\_64 -kernel /boot/vmlinuz-\`uname -r\` 这会提示缺少文件系统 可以使用 debootstrap 构建一个rootfs ``` IMG=qemu-image.img DIR=mount-point.dir qemu-img create $IMG 1g mkfs.ext2 $IMG mkdir $DIR sudo mount -o loop $IMG $DIR sudo debootstrap –arch amd64 jessie $DIR sudo umount $DIR rmdir $DIR 这里最好用一下 chroot 和 passwd 更新一下文件系统里的密码,以免启动之后登不进去。

git 中心服务搭建

中心服务方式选择 git 本身是一个分布式的版本管理系统,但如果要设置一个中心库方便很多开发者同步,或者像SVN 一样使用它,就需要搭建一个中心库。有几种方式可以选择: gitosis : 这个是比较老的方式。不推荐 详情参考: https://git-scm.com/book/en/v1/Git-on-the-Server-Gitosis GitLab: git 结合web 服务来管理,方便issue 和权限管理。比较推荐。收费版还可提供更多功能。参考:https://about.gitlab.com/install/ 只用ssh git 用户管理 开一个git 用户,设定好权限,也比较方便。但是缺少管理issue 功能。 参考:https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server ssh git用户设置  ssh key证书生成 $ ssh-keygen –t rsa –C “user@host”  将id_rsa.pub 发给git服务器管理员添加进/home/git/.ssh/authorized_keys 即可,或者直接用 ssh-copy-id 到服务器即可。 $ git clone git@IP:/srv/git/test.git 有几个注意点: 使用 ssh key 登陆 git 用户时,home目录只能是git 可写的,否则当git组包含多个用户时会出现不用能ssh key 登录的问题。具体debug ssh key 登录问题,可以查看 /var/log/auth 下的日志来解决。.ssh/ 的权限是700,.ssh/authorized_keys 权限是600。 最后用chsh 修改 git用户shell 为 git-shell,不让git 用户有其它多余的权限。 创建仓库可以用git 组的其它用户来创建。注意使用newgrp 将创建文件夹时用户的默认组改成git, 这样整个git 组的用户都有读写权限。 一些实用的git 命令记录 git checkout --patch BRANCH FILE git checkout --theirs PATH/FILE git clean -n //演习 git ls-files git ls-files | xargs -n 1 dirname | uniq git diff master sync --name-only git config --global core.

YUV 图像格式

Y:亮度分量 UV:色度分量 Y与RGB的演算关系为:Y = 0.2126 R + 0.7152 G + 0.0722 B YUV4:2:2或4:2:0都是指的Y分量和UV分量在一个像素点中占有的平均比例。 YUV422:水平方向上的UV分量减半了 YUV420:水平垂直方向都会减半 YUV 4:4:4采样,每一个Y对应一组UV分量。 eg: YUVYUV YUV 4:2:2采样,每两个Y共用一组UV分量。 eg: YUYVYUYV YUV 4:2:0采样,每四个Y共用一组UV分量。 eg: YUYVYUYV YYYY  以黑点表示采样该像素点的Y分量,以空心圆圈表示采用该像素点的UV分量。

嵌入式linux 开发中常用工具安装笔记

Samba server  \# apt install samba samba-common # vim /etc/samba/smb.conf 添加: security = user \[shuji\] comment = share dir path = /srv/samba browseable = yes writable = yes # useradd public (不要用adduser, 否则还要禁用shell) # smbpasswd –a public # service smbd restart Samba client smbclient -L //192.168.1.10 -U dev smbclient //192.168.1.10 -U dev   nfs \# vim /etc/exports /srv/nfs *(rw,sync,nosubtree_check)

petalinux use guide summarize

petalinux 是针对 Xilinx FPGA-based SOC designs 的 embedded linux system development kit 。 包含了: Yocto Extensible SDK Minimal downloads XSCT and tool chains PetaLinux CLI tools 详情参考 PetaLinux Tools Reference Guide。 **版本: v2018.2 June 6, 2018 ** 不支持 ubuntu1804, 手贱装了ubuntu1804, 结果 build 的时候出现 Bitbake 运行不起来,google 一遍发现这版本petalinux 还是暂时不支持 ubuntu1804 ,遂重新装回1604. 总结: petalinux 安装, 略。 BSP 安装 BSP 是petalinux 的一个参考开发板的基础配置。可以把它作为一个模板创建自己的工程。它提供 了一个 installable BSP files,包含了所有必要的 design 和 configuration files ,pre-built 和 tested hardwrae 和 software images.

recent new tech need to analysis and learn

reverse ssh tunnel nohup ssh -NfR 2222:localhost:22 root@106.12.13.xxx -p22 expect script strip command Some useful line editing key bindings provided by the Readline library: Ctrl-A: go to the beginning of line Ctrl-E: go to the end of line Alt-B: skip one word backward Alt-F: skip one word forward Ctrl-U: delete to the beginning of line Ctrl-K: delete to the end of line Alt-D: delete to the end of word https://askubuntu.

c/c++编译相关技巧总结帖

链接时忽略文件中未用到的函数或者对象。这在移植代码过程中很有用, 我们就不需要去删除或者注释掉那些大量没用到的对象或者不需要去链接的对象。 For GCC, this is accomplished in two stages: First compile the data but tell the compiler to separate the code into separate sections within the translation unit. This will be done for functions, classes, and external variables by using the following two compiler flags:-fdata-sections -ffunction-sections Link the translation units together using the linker optimization flag (this causes the linker to discard unreferenced sections):-Wl,--gc-sections So if you had one file called test.

网站迁移笔记

迁移参考: https://www.digitalocean.com/community/tutorials/how-to-move-an-apache-web-root-to-a-new-location-on-ubuntu-16-04 Ubuntu1604 安装php5.6 由于Ubuntu1604 默认安装的是php7。由于网站兼容性问题,需要装php5。 步骤参考:https://phpraxis.wordpress.com/2016/05/16/install-php-5-6-or-5-5-in-ubuntu-16-04-lts-xenial-xerus/ > add-apt-repository ppa:ondrej/php > apt-get update > apt-get install php5.6 php5.6-mbstring php5.6-mysql php5.6-sqlite3 > 还有这些按需要装 php5.6-cli php5.6-curl php5.6-json php5.6-mcrypt php5.6-curl php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0 mysql-server-5.7 apache2 # php 版本切换方法2 > sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart ; echo 1 | sudo update-alternatives –config php > sudo a2dismod php5.6 ; sudo a2enmod php7.

linux bash shell 像cmd.exe 一样的滚动补齐功能

有些情况下,比如我们遇到文件名含有一些字符不容易输入时就很着急了,这时候就需要让linux shell像windows cmd.exe 一样自动补全部的文件名,且可自动按顺序一个个滚动切换。方法如下: 在用户目录创建 ~/.inputrc (若不存在则自己创建) 文件里添加一行: [code]TAB: menu-complete[/code] 。 登出再登陆用户就可以了。 For more details see the READLINE section in man bash .

gdb 简记

常用命令如下:(详情可以用 help 命令查看) r (run, restart) s (step into) n (next state, step over) finish (step out) q (quit) p (print anything you want) l (list) b (breakpoint) #设置断点: (gdb) b fileName.c:lineNumber 或者 (gdb) b function u (until) #运行到指定行 call #调用函数 set #设置变量 set args #设置main 的输入参数 bt (backtrace) #查看堆栈 x #examine memory, (gdb)/FMT ADDRESS info # show things, (gdb) info break d # delete somthing (gdb) delete break xx 或者 (gdb) clean lineNumber 如果print 的内容比较长导致后面的内容是…,可以重新设置print长度的上限,或者无限制: set print element 0 如果要生成带调试信息的程序,在gcc时要加上-g参数。 target remote 192.