加上这三行就可以了
RUN pip install -U pip
RUN pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
RUN pip config set install.trusted-host mirrors.aliyun.com
加上这三行就可以了
RUN pip install -U pip
RUN pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
RUN pip config set install.trusted-host mirrors.aliyun.com
在 Linux 开发中我们时常会遇到对于之前进程 kill 掉,然后再运行当前进程或程序的情况,此时我们是不知道需要 kill 的进程号的,那么就需要通过一个 shell 命令组合来实现这个需求。
如下命令可以实现:
ps a | grep -w nameprocess | grep -v grep| cut -c 1-6 | xargs kill -9
说明:
ps axu|grep nameprocess | awk '{print "kill -9 "}'
cd u-boot
tools/mkimage -n ${PLAT} -T rksd -d ${TPL_BIN} idbloader.img
cat ${SPL_BIN} >> idbloader.img
1、脚本方式
cd uboot
# 打包官方提供的ddr与miniloader的bin文件
./make.sh --idblock ../rkbin/RKBOOT/xxxx.ini
# 打包自己编译的tpl与spl的bin文件
./make.sh --idblock --tpl --spl ../rkbin/RKBOOT/xxxx.ini
2、mkimage方式
./tools/mkimage -n ${PLAT} -T rksd -d ${TPL_BIN}:${SPL_BIN} idblock.bin
3、生成的 idblock.bin 与 idbloader.img 是一样的,重命名就行:
mv idblock.bin idbloader.img
arm系统不同于x86服务器,可能是因为外设驱动的问题,无法在启动阶段通过编辑grub进入单用户模式而得以修改root的密码。所以,可如下操作:
1、用其他外置启动盘启动系统,通常是U盘
2、挂载原系统(在eMMC)上的文件系统的 /etc目录
3、vi该目录下的shadow,删除其中root之后两个冒号之间的加密密码
4、保存、退出vi,sync并且shutdown系统
5、拔除外置启动盘,重加电启动原系统
6、此时root已无需密码即可登录,登录后及时passwd修改密码
spi-flash系统生成需要进行四部曲: “uboot” 、 “dtb” 、“kernel” 和 “rootfs” 。以16M flash举例, 介绍 spi flash 的适配过程。 分区表如下:
分区序号 | 分区大小 | 分区作用 | 地址空间及分区名 |
mtd0 | 1MB (0x100000) | spl+uboot | 0x0000000-0x0100000 : “uboot” |
mtd1 | 64KB (0x10000) | dtb文件 | 0x0100000-0x0110000 : “dtb” |
mtd2 | 4MB (0x400000) | linux内核 | 0x0110000-0x0510000 : “kernel” |
mtd3 | 剩余 (0xAF0000) | 根文件系统 | 0x0510000-0x1000000 : “rootfs” |
# 此处为获取7.2.1版本,您可获取其他版本或者通过链接直接下载
wget http://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabi/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz
tar -vxJf gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz
sudo cp -r ./gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi /opt/
sudo vim /etc/bash.bashrc
# 在文件末尾 添加以下内容
PATH="$PATH:/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi/bin"
# 添加完毕
# 使路径生效
source /etc/bash.bashrc
此时可用 arm-linux-gnueabi-gcc -v
进行测试;若普通用户状态下没有成功,通过 sudo su
切换到root用户再尝试;
1、从GitHub下载uboot源码
sudo apt-get install git git clone https://github.com/Lichee-Pi/u-boot.git cd u-boot # 查看分支 git branch -a # 切换到 Nano 分支 git checkout nano-v2018.01
2、uboot源码结构
.
├── api //封装一些平台无关的操作,如字符串打印,显示,网络,内存
├── arch //以平台架构区分
│ ├──arm
│ │ └──cpu
│ │ │ └──arm926ejs
│ │ │ │ └──sunxi //cpu相关的一些操作,如定时器读取
│ │ │ │ │ └──u-boot-spl.lds //spl的放置方法
│ │ └──dts
│ │ │ └──suniv-f1c100s-licheepi-nano.dts // f1c100s芯片的一些配置
│ │ │ └──suniv-f1c100s-licheepi-nano.dtb
│ │ │ └──suniv-f1c100s.dtsi
│ │ │ └──suniv.dtsi
│ │ └──lib //一些库文件
│ │ └──mach-sunxi
│ │ │ └──board.c //board_init_f
│ │ │ └──dram_sun4i.c //ddr的操作,复位,时钟,延时,odt,etc.
│ │ │ └──dram_helpers.c //ddr的设置及读写测试
├── board
│ ├──sunxi
│ │ └──board.c //sunxi_board_init 入口
│ │ └──dram_suniv.c //DRAM的一些默认参数
├── cmd //Uboot命令行的一些命令
├── common //含spl
├── configs //menuconfig里的默认配置,比如各类驱动适配
│ ├── licheepi_nano_defconfig
│ ├── licheepi_nano_spiflash_defconfig
├── disk //硬盘分区的驱动
├── doc
├── drivers //外设驱动
├── dts
├── examples
├── fs //多种文件系统
├── include
│ ├──configs
│ │ └──sunxi_common.h //预配置的参数,如串口号等
│ │ └──suniv.h
├── lib //加密压缩等算法
├── net //nfs,tftp等网络协议
├── post
├── scripts
3、uboot配置
# 此处告知make采用arm-linux-gnueabi下的所有交叉编译工具,目标架构为Arm,设定各项默认配置为 nano 的spiflash支持版
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- licheepi_nano_spiflash_defconfig
# 若不带spi-flash的板子,请换成 licheepi_nano_defconfig
修改文件uboot源码目录下 进入 ./include/configs/suniv.h
#define CONFIG_BOOTCOMMAND "sf probe 0:50000000; " \
"sf read 0x80C00000 0x100000 0x4000; " \
"sf read 0x80008000 0x110000 0x400000; " \
"bootz 0x80008000 - 0x80C00000"
# 进行可视化配置
make ARCH=arm menuconfig
#取消勾选 [ ] Enable a default value for bootcmd
#勾选 [*] Enable boot arguments;
#在下方一项中填入 bootargs 参数:
console=ttyS0,115200 panic=5 rootwait root=/dev/mtdblock3 rw rootfstype=jffs2
#(root=/dev/mtdblock3 指的是mtd设备第三分区,分区指定在dts中声明)
4、添加LCD支持
ARM architecture ‣ Enable graphical uboot console on HDMI, LCD or VGA 为 Y
#接着配置同级的 LCD panel timing details 为:
#分辨率800*480
x:800,y:480,depth:18,pclk_khz:33000,le:87,ri:40,up:31,lo:13,hs:1,vs:1,sync:3,vmode:0
#分辨率480*272
x:480,y:272,depth:18,pclk_khz:10000,le:42,ri:8,up:11,lo:4,hs:1,vs:1,sync:3,vmode:0
并将 LCD panel backlight pwm pin 设为:PE6 (管脚参照原理图)
5、uboot编译
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j4
编译完成后,可一看到目录下多了一堆以u-boot带头的文件,我们只需取 u-boot-sunxi-with-spl.bin 即可。
1、从GitHub下载Linux源码
#下载代码
git clone --depth=1 -b f1c100s-480272lcd-test https://github.com/Icenowy/linux.git
下载配置文件:
下载 .config 文件,放入源码主目录进行替换 (若下载时文件名有变,请重命名回 .config );
2、DTS修改
修改内核源码目录下的 ./arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins_a>;
status = "okay";
spi-max-frequency = <50000000>;
flash: w25q128@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "winbond,w25q128", "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x000000 0x100000>;
read-only;
};
partition@100000 {
label = "dtb";
reg = <0x100000 0x10000>;
read-only;
};
partition@110000 {
label = "kernel";
reg = <0x110000 0x400000>;
read-only;
};
partition@510000 {
label = "rootfs";
reg = <0x510000 0xAF0000>;
};
};
};
};
此处在dts中为mtd设备预先划分好了分区内容,内核将会自动解析 。
3、内核配置修改
#打开可视化配置窗口
make ARCH=arm menuconfig
勾选 File systems ‣ Miscellaneous filesystems ‣ Journalling Flash File System v2 (JFFS2) support 。
勾选 Device Drivers -> Memory Technology Device (MTD) support ,及下面子项:
勾选 Device Drivers -> SPI support ,及下面子项:
Allwinner A31 SPI Controller (勾选)
Allwinner A10 SoCs SPI controller (不勾选)
修改源码下的 ./drivers/mtd/ spi-nor/ spi-nor.c
修改对应spi-flash;如 w25q128 :
{ "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) },
// 修改为 (不使用sector,使用块擦除):
{ "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, 0) },
4、内核编译
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j4 #请自行修改编译线程数
生成的 zImage 在 arch ‣ arm ‣ boot 目录下
编译工具链为 arm-linux-gnueabi,工具链的安装请参考 uboot 编译部分 。
进入Linux目录,执行如下代码:
设备树在源码的 linux ‣ arch ‣ arm ‣ boot ‣ dts ‣ suniv-f1c100s-licheepi-nano.dts;
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- dtbs -j4
生成的 dtb文件 在 dts同级目录下 。
1、下载依赖包
apt-get install linux-headers-$(uname -r)
2、buildroot下载配置
wget https://buildroot.org/downloads/buildroot-2017.08.tar.gz
tar xvf buildroot-2017.08.tar.gz
cd buildroot-2017.08/
make menuconfig
Target options --->
Target Architecture Variant (arm926t) ---> // arm926ejs架构
[ ] Enable VFP extension support // Nano 没有 VFP单元,勾选会导致某些应用无法运行
Target ABI (EABI) --->
Floating point strategy (Soft float) ---> // 软浮点
System configuration --->
(Lichee Pi) System hostname // hostname
(licheepi) Root password // 默认账户为root 密码为licheepi
[*] remount root filesystem read-write during boot // 启动时重新挂在文件系统使其可读写
3、编译
若编译时,buildroot下载软件包速度太慢,请下载 dl.zip ,将其中的软件包解压至 buildroot ‣ dl 下;
#编译命令:
make
编译完成的镜像包,是在 buildroot-2017.08 ‣ output ‣images ‣ rootfs.tar 中找到 。
脚本下载:
把.txt改成.sh。
UBOOT版本:2018.01
实验目标:u-boot启动后点亮3个led灯
u-boot启动过程中会调用crt0.S汇编代码,在该汇编代码中点亮LED.
LED对于引脚如下:
REG –GPE4
GREEN – GPE5
YELLOW – GPE6
1、GPIO驱动实现
u-boot的驱动程序都放在drivers目录下。
LED驱动属于GPIO驱动。
所以led驱动应该写在drivers\gpio目录下,下面是已经实现的sunxi_gpio.c驱动。
详细代码可查阅:u-boot-nano-v2018.01\drivers\gpio\sunxi_gpio.c
sunxi_gpio.c里的函数在u-boot-nano-v2018.01/include/asm-generic/gpio.h头文件中被声明。
2、LED驱动实现,这部前需要先实现上面的GPIO驱动
在board目录下添加led.c,代码如下
#include <common.h>
#include <asm/io.h>
#include <asm/arch/gpio.h>
#include <status_led.h>
#include <asm-generic/gpio.h> /*下面函数在这个头文件中声明*/
//int gpio_direction_output(unsigned gpio, int value);
//初始化 LED(PE4、PE5、PE6)
void coloured_LED_init(void)
{
/* Clock is enabled in board_early_init_f() */
//gpio_direction_output函数在u-boot-nano-v2018.01\drivers\gpio\sunxi_gpio.c中实现,这里直接调用就可以了
gpio_direction_output(CONFIG_RED_LED, 0);
gpio_direction_output(CONFIG_GREEN_LED, 0);
gpio_direction_output(CONFIG_YELLOW_LED, 0);
}
#ifdef CONFIG_RED_LED
void red_led_on(void)
{
gpio_set_value(CONFIG_RED_LED, 1);
}
void red_led_off(void)
{
gpio_set_value(CONFIG_RED_LED, 0);
}
#endif
#ifdef CONFIG_GREEN_LED
void green_led_on(void)
{
gpio_set_value(CONFIG_GREEN_LED, 1);
}
void green_led_off(void)
{
gpio_set_value(CONFIG_GREEN_LED, 0);
}
#endif
#ifdef CONFIG_YELLOW_LED
void yellow_led_on(void)
{
gpio_set_value(CONFIG_YELLOW_LED,1);
}
void yellow_led_off(void)
{
gpio_set_value(CONFIG_YELLOW_LED, 0);
}
#endif
注意:#include <asm-generic/gpio.h> 头文件不能少。
然后编辑led.c同目录下的Makefile文件,把led.o编译进去。
Makefile中添加如下一行:
obj-$(CONFIG_SUNXI_LED ) += led.o
3、配置声明
在include/configs/suniv.h中添加如下声明。
#define CONFIG_SUNXI_LED 1 /*开启LED支持*/
#define CONFIG_RED_LED 132 /*PGE4*/
#define CONFIG_GREEN_LED 133 /*PGE5*/
#define CONFIG_YELLOW_LED 134 /*PGE6*/
4、在crt0.S汇编代码中点亮LED
在crt0.S中调用以下函数点亮3个led灯:
bl coloured_LED_init
bl red_led_on
bl green_led_on
bl yellow_led_on
5、编译下载:
cd “你的uboot目录”
# 编译
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j8
# usb下载u-boot目标板
sunxi-fel uboot ./u-boot-sunxi-with-spl.bin
对于Linux系统添加自启动供能,想必大家都是耳熟能详,一般是把需要启动的脚本或者程序添加到 /etc/rc.d/rc.local 文件里就好了,但是在这里你错了,openwrt并不是这么实现的。而是通过另外一种方式,采用存放在/etc/init.d目录下的脚本连接到/etc/rc.d目录下,并且这个脚本需要遵循一定的规则。举例如下:
1、vi /etc/init.d/mystart
2、输入以下内容
#!/bin/sh /etc/rc.common
# Example script
START=10
STOP=15
start() {
echo start
# commands to launch application
}
stop() {
echo stop
# commands to kill application
}
3、 然后保存,退出
4、获取执行权限及映射
cd /etc
chmod -R 777 init.d/mystart #设置权限,否则无法激活开机启动,提示权限不足
/etc/init.d/mystart enable #激活开机启动
/etc/init.d/mystart start #运行start函数启动程序
5、脚本说明
第一行#! 使用 /bin/sh /etc/rc.common 作为脚本解释器并在执行脚本前调用 main 和检查脚本。
公用的 init script 方法:
start # 启动服务
stop # 停止服务
restart # 重启服务
reload # 重新载入配置文件, 如果失败则重启
enable # 启用开机自启动
disable # 禁用开机自启动
脚本中 start() 和 stop() 是必须的
START= 和 STOP= 决定脚本启动时的次序. 启动时init.d会根据文件名顺序, 自动执行在/etc/rc.d中找到的脚本. 初始化脚本可以作为/etc/init.d/下文件的软链放置在/etc/rc.d/. enable 和 disable 可以自动帮你创建对应的带序号的软链.