linux编译运行uart,Kindle4: 编译并运行upstream linux kernel – v4.4
Kindle4官方提供的Linux kernel版本为2.6.31, 已经算是很旧版本的kernel了。当前最新版本的linux kernel为4.5,而brillo-m10-dev arm emulator所使用的版本为v4.4,对于 CPU主频只有800MHz并且RAM为256MB的Kindle4来说,跑个Brillo-m10-dev系统还是很不错的。Kindle4的优点是有PMIC(电源管理),有fuel gauge,有WiFi,当然,还有一个USB 2.0接口,使用USB协议的adb比TCP协议的adb要好用很多(master分支上的adb已经支持TCP协议断开检查,并且解决了在执行adb reboot命令没有回应的问题)。
相关开发环境:
1. 主机系统: ubuntu-14.04 x86_64
2. 编译工具: arm-eabi-4.6 – https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/
3. 烧机工具:fastboot – http://www.mobileread.com/forums/showthread.php?t=174923
文件结构
kindle4
|-- Fastboot-Kindle
| `-- fastboot
|-- tools
| `-- arm-eabi-4.6
|-- u-boot-2009.08
| `-- u-boot-bist-kernel
`-- v4.4
`-- arch
`-- arm
`-- boot
|-- dts
| `-- imx50-evk.dtb
`-- zImage
1. Fastboot-Kindler包含fastboot源代码及fastboot可执行程序,用于烧写u-boot-bist-kernel
2. u-boot-2009.08包含kindle4 u-boot 4.1.3版本源代码
3. tools/arm-eabi-4.6 编译u-boot代码所需要的工具链
4. v4.4 包含linux kernel v4.4源代码及编译好的zImage与imx50-evk.dtb文件
bootloader – u-boot
需要修改u-boot,以便能够引导使用Flattened Device Tree(FDT) 的kernel。相关的patch文件可以从这里下载:kindle4_v4.1.3_u-boot-bist_fdt.patch,编写u-boot-kernel-v4.4.its文件:
/*
* Simple U-boot uImage source file containing a single kernel and FDT blob
*/
/dts-v1/;
/ {
description = "i.MX508 Linux kernel and FDT blob";
#address-cells = <1>;
images {
kernel@1 {
description = "i.MX508 Linux kernel";
data = /incbin/("../v4.4/arch/arm/boot/zImage");
type = "kernel";
arch = "arm";
os = "linux";
compression = "none";
load = <0x70008000>;
entry = <0x70008000>;
hash@1 {
algo = "crc32";
};
hash@2 {
algo = "sha1";
};
};
fdt@1 {
description = "Flattened Device Tree blob";
data = /incbin/("../v4.4/arch/arm/boot/dts/imx50-evk.dtb");
type = "flat_dt";
arch = "arm";
compression = "none";
hash@1 {
algo = "crc32";
};
hash@2 {
algo = "sha1";
};
};
};
configurations {
default = "conf@1";
conf@1 {
description = "i.MX508 Boot Linux kernel with FDT blob";
kernel = "kernel@1";
fdt = "fdt@1";
};
};
};
从这里可以看到编译出来的kernel存放在../v4.4/arch/arm/boot/zImage, 而dtb文件为../v4.4/arch/arm/boot/dts/imx50-evk.dtb。
最后执行如下脚本,就可以生成我们所需要的烧机文件:u-boot-bist-kernel
#! /bin/bash
set -e
TP="`pwd`/../tools/arm-eabi-4.6"
if [ ! -f include/config.h ] ; then
CROSS_COMPILE=${TP}/bin/arm-eabi- ARCH=arm TYPE=bist make imx50_yoshi_bist_config
fi
CROSS_COMPILE=${TP}/bin/arm-eabi- ARCH=arm TYPE=bist make $@
if [ -f u-boot.bin ] ; then
tools/mkimage -A arm -O linux -T kernel -C none -a 0x79800000 -e 0x79800000 -n 'u-boot-bist' -d u-boot.bin u-boot-bist-kernel
tools/mkimage -f u-boot-kernel-v4.4.its u-boot-kernel-v4.4
dd if=u-boot-kernel-v4.4 of=u-boot-bist-kernel bs=$((1024*1024)) seek=1
fi
NOTE:由于生成最终的u-boot-bist-kernel文件需要zImage与imx50-vvk.dtb,所以在执行这个脚本时需要保证这两个文件已经存在。
执行如下命令将u-boot-bist-kernel写入到kernel分区:
hzak@B85RPI:~/kindle4/u-boot-2009.08$ ../Fastboot-Kindle/fastboot flash kernel u-boot-bist-kernel && ../Fastboot-Kindle/fastboot reboot
系统重启后会自动进入我们编译出来的u-boot – bist系统,这时候执行如下命令可以正常启动linux系统:
...
In: serial
Out: serial
Err: serial
POST done in 1 ms
Battery voltage: 3712 mV
bist > bootm 0x141000
## Booting kernel from FIT Image at 7a000000 ...
Using 'conf@1' configuration
Trying 'kernel@1' kernel subimage
Description: i.MX508 Linux kernel
Type: Kernel Image
Compression: uncompressed
Data Start: 0x7a0000dc
Data Size: 4240184 Bytes = 4 MB
Architecture: ARM
OS: Linux
Load Address: 0x70008000
Entry Point: 0x70008000
Hash algo: crc32
Hash value: d85b369e
Hash algo: sha1
Hash value: 363136b407684d3d58119823f819501f9f254399
Verifying Hash Integrity ... crc32+ sha1+ OK
## Flattened Device Tree from FIT Image at 7a000000
Using 'conf@1' configuration
Trying 'fdt@1' FDT blob subimage
Description: Flattened Device Tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x7a40b53c
Data Size: 10230 Bytes = 10 kB
Architecture: ARM
Hash algo: crc32
Hash value: 682b5aa0
Hash algo: sha1
Hash value: c336f63fd6f4e82d21439ca2843a99eea47f03bb
Verifying Hash Integrity ... crc32+ sha1+ OK
Booting using the fdt blob at 0x7a40b53c
Loading Kernel Image ... OK
OK
Loading Device Tree to 71ffa000, end 71fff7f5 ... OK
Starting kernel ...
kernel – v4.4.2
为了使Kindle4能跑brillo-m10-dev系统,kernel版本当然是使用v4.4了。相关的commit为:
commit 96cb1584b08c9a74a7cce6805354d4515c2131ae
Author: Greg Kroah-Hartman
Date: Wed Feb 17 12:31:25 2016 -0800
Linux 4.4.2
目前能够正常工作的设备有:
1. uart1 – 输出kernel log,用于kernel调试
diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
index a634b11..9755a46 100644
--- a/drivers/clk/imx/clk.c
+++ b/drivers/clk/imx/clk.c
@@ -101,12 +101,14 @@ void __init imx_register_uart_clocks(struct clk ** const clks[])
static int __init imx_clk_disable_uart(void)
{
+#if 0
if (imx_keep_uart_clocks && imx_uart_clocks) {
int i;
for (i = 0; imx_uart_clocks[i]; i++)
clk_disable_unprepare(*imx_uart_clocks[i]);
}
+#endif
return 0;
}
不能disable uart时钟,否则会死机。why?
2. esdhc3 – 读写eMMC
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 1f1582f..114dcd2 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1267,7 +1267,7 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev)
ret = sdhci_runtime_suspend_host(host);
if (!sdhci_sdio_irq_enabled(host)) {
- clk_disable_unprepare(imx_data->clk_per);
+// clk_disable_unprepare(imx_data->clk_per);
clk_disable_unprepare(imx_data->clk_ipg);
}
clk_disable_unprepare(imx_data->clk_ahb);
@@ -1282,7 +1282,7 @@ static int sdhci_esdhc_runtime_resume(struct device *dev)
struct pltfm_imx_data *imx_data = pltfm_host->priv;
if (!sdhci_sdio_irq_enabled(host)) {
- clk_prepare_enable(imx_data->clk_per);
+// clk_prepare_enable(imx_data->clk_per);
clk_prepare_enable(imx_data->clk_ipg);
}
clk_prepare_enable(imx_data->clk_ahb);
在runtime suspend的时候不能disable per(外设时钟)。why?
USB 目前还存在问题,不能正常工作。
相关的编译脚本如下:
#! /bin/bash
TP="`pwd`/../tools/arm-eabi-4.6"
if [ ! -f .config ] ; then
CROSS_COMPILE=${TP}/bin/arm-eabi- ARCH=arm make imx_v6_v7_defconfig
fi
CROSS_COMPILE=${TP}/bin/arm-eabi- ARCH=arm make $@
相关的参考文档:
http://www.devicetree.org/Main_Page
linux编译运行uart,Kindle4: 编译并运行upstream linux kernel – v4.4相关推荐
- kindle运行linux命令,Kindle4: 编译并运行官方linux kernel – v2.6.31
在Kindle4的源码包中,也包含kernel的代码: 4.0, 4.0.1版本kernel代码一样,4.1.0版本独立的一个版本,而4.1.1, 4.1.2,4.1.3版本kernel也是一样的,所 ...
- linux编译运行uart,搭建 linux 下的编译环境,使用 uart1 双线串口作为 console
我平时的开发都是在 linux 下进行的,这也是我第一次学习 RISC-V 处理器.所以就想从头开始学习了.搭建编译环境,主要就是一个编译工具链 riscv64-unknown-elf-gcc.工具链 ...
- linux arm 无法执行二进制文件,qemu-arm无法运行arm编译的二进制文件
我使用qemu,qemu-user和安装的gnueabi工具链运行Linux Mint 14.我用arm-linux-gnueabi-gcc test.c -o test编译了test.c.qemu- ...
- 在linux中配置编译u-boot方法,在ZC702上运行Linux(4)-编译和使用U-Boot Linux
1. 安装工具链 如网页上所说,安装包xilinx-2011.09-50-arm-xilinx-linux-gnueabi.bin提示系统是dash,而安装包需要bash.按照提示运行命令 sudo ...
- c 运行 java linux命令行参数,Linux下用命令行编译运行Java总结
最近使用腾讯云的Cloud Studio写Java,只能使用命令行进行编译运行,趁此机会,学习一下Linux的一些常用命令.平时windows下IDE用习惯了,现在用命令行进行编译运行,发现其实问题还 ...
- linux怎么用gcc运行程序设计,linux应用程序设计--GCC程序编译
GCC程序编译 linux系统下的GCC(GNU C Compiler)是GNU推出的功能强大.性能优越的多平台编译器,是GNU的代表作之一.GCC可以在多种硬件平台上编译出可执行程序,其执行效率与一 ...
- linux如何编译wine,利用winelib编译一个可在linux下运行的程序
利用winelib编译一个可在linux下运行的程序 只是想既可以使用linux的api,又可以使用windows的api #include #include #include #include in ...
- Linux下编译、链接、加载运行C++ OpenCV的两种方式及常见问题的解决
Linux下编译.链接.加载运行C++ OpenCV的两种方式及常见问题的解决 在Linux下安装完OpenCV C++之后(还没有安装的读者请参考Ubuntu 18.04 安装OpenCV C++) ...
- Linux下开启openmp编译,OpenMP程序的编译和运行
<OpenMP程序的编译和运行>由会员分享,可在线阅读,更多相关<OpenMP程序的编译和运行(13页珍藏版)>请在人人文库网上搜索. 1.SHANGHAI UNIVERSIT ...
最新文章
- android上line-height的问题
- l293d电机驱动原理_一文搞懂步进电机特性、原理及驱动器设计
- 新人新博客新学习家园
- 火狐对ajax的onreadystatechange与IE的不同。
- SpringBoot2.1版本的个人应用开发框架 - 集成Druid + MybatisPlus
- centos6 与 7 其中的一些区别
- jQuery打印插件JQPRINT
- VMWARE虚拟机使用的是此版本 VMware Workstation 不支持的硬件版本。 模块“Upgrade”启动失败。 未能启动虚拟机。
- 小程序中wx-if使用方法
- Python正则表达式清洗微博文本特殊符号(网址, @, 表情符等)
- openlayers5之ol.proj坐标转换
- 2022/3/21-2022/3/22
- 观黄梅戏《打猪草》有感
- (十二)python图形用户界面
- do vis是什么意思_BBC听力: 2020年2月8日 小宠物为什么可以找到回家的路
- PLSQL导出数据空表设置
- 异常处理-No SecurityManager accessible to the calling code
- 了解MD5---笔记
- 如何在 Linux 和 Windows 之间共享 Steam 的游戏文件
- 【数论 G】B045_约数之和(枚举 | 快速幂)