100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > openwrt运行linux软件 使用OpenWrt开发嵌入式Linux(二):先让系统跑起来(使用initramfs)...

openwrt运行linux软件 使用OpenWrt开发嵌入式Linux(二):先让系统跑起来(使用initramfs)...

时间:2021-10-31 14:30:34

相关推荐

openwrt运行linux软件 使用OpenWrt开发嵌入式Linux(二):先让系统跑起来(使用initramfs)...

安装相关工具(推荐使用ubuntu 16及以上版本)

sudo apt install gcc binutils bzip2 flex python perl make diffutils unzip gawk subversion zlib1g-dev quilt

下载源码

git clone /openwrt/openwrt.git

cd openwrt

开始编译前的准备工作——更新软件包

./scripts/feeds update -a

./scripts/feeds install -a

配置 —— menuconfig

make menuconfig

Target System (Samsung s3c24xx/s5pv210) --->

Subtarget (s5pv210 based boards) --->

Target Profile (TQ210) --->

Target Images --->

[*] ramdisk --->

Global build settings --->

Kernel build options --->

[*] Compile the kernel with early printk

选择TQ210硬件平台

选择ramdisk,使用内存文件系统启动

选中内核早期调试打印

配置内核 —— make kernel_menuconfig

make kernel_menuconfig

Boot options --->

[*] Use appended device tree blob to zImage (EXPERIMENTAL)

Kernel hacking --->

[*] Kernel low-level debugging functions (read help!)

Kernel low-level debugging port (Use Samsung S3C UART 0 for low-level debug) --->

选中将dtb追加到zImage后面

根据自己的开发板选择调试串口,TQ210使用的是UART0

在这里可以把一些暂时不需要的配置选项给去掉

编译

make -j4

编译成功,我们最终需要的内核如下

bin/targets/samsung/s5pv210/openwrt-samsung-s5pv210-tq210-initramfs-kernel.bin

这里编译出来的内核是uImage格式,如果需要zImage格式,请修改target/linux/samsung/image/Makefile,将uImage none去掉

define Device/Default

PROFILES = Default

KERNEL_NAME := zImage

KERNEL := kernel-bin | append-dtb

endef

使用tftp下载内核到设备的内存直接运行

我这里使用我自己移植的barebox(一个代码风格类似Linux的Bootloader)来运行内核

barebox .04.0-00135-g476dd0f26-dirty #5 Fri Apr 13 01:21:34 CST

Board: Embedsky tq210

netconsole: registered as netconsole-1

dm9000 dm90000: Found DM9000B at i/o: 0x88000000

mdio_bus: miibus0: probed

nand: NAND device: Manufacturer ID: 0xec, Chip ID: 0xd3 (Samsung NAND 1GiB 3,3V 8-bit), 1024MiB, page size: 2048, OOB size: 64

Scanning device for bad blocks

Bad eraseblock 1402 at 0x00000af40000

registered as fbconsole0

malloc space: 0x2bf00000 -> 0x2fefffff (size 64 MiB)

refclk: 24000 kHz

armclk: 1000000 kHz

a2mclk: 200000 kHz

hclk_dsys: 166750 kHz

pclk_dsys: 83375 kHz

hclk_psys: 133400 kHz

pclk_psys: 66700 kHz

running /env/bin/init...

nv variable modified, will save nv variables on shutdown

Hit m for menu or any other key to stop autoboot: 0

type exit to get to the menu

barebox@Embedsky tq210:/

使用tftp命令下载内核。Barebox支持ramfs,这里直接下载到ramfs中

barebox@Embedsky tq210:/ tftp openwrt-samsung-s5pv210-tq210-initramfs-kernel.bin

WARNING: net: warning: No MAC address set. Using random address fa:09:66:1f:1a:d7

eth0: 100Mbps full duplex link detected

T [#################################################################]

Barebox支持将文件作为命令直接执行

barebox@Embedsky tq210:/ ./openwrt-samsung-s5pv210-tq210-initramfs-kernel.bin

Image Name: ARM OpenWrt Linux-4.14.32

Created: -04-13 14:09:27 UTC

OS: Linux

Architecture: ARM

Type: Kernel Image

Compression: uncompressed

Data Size: 3876720 Bytes = 3.7 MiB

Load Address: 20008000

Entry Point: 20008000

Loading U-Boot uImage './openwrt-samsung-s5pv210-tq210-initramfs-kernel.bin'

commandline: mtdparts=nand:256k(nand0.barebox),128k(nand0.bareboxenv),4M(nand0.kernel),-(nand0.rootfs)

arch_number: 0

nv variables modified, saving them

Uncompressing Linux... done, booting the kernel.

[ 0.000000] Booting Linux on physical CPU 0x0

[ 0.000000] Linux version 4.14.32 (zjh@zjh-GE60-2PL) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 r6740-31293c675c)) #0 PREEMPT Fri Apr 13 14:09:27

[ 0.000000] CPU: ARMv7 Processor [412fc082] revision 2 (ARMv7), cr=10c5387d

[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache

[ 0.000000] OF: fdt: Machine model: Embedsky TQ210 based on S5PV210

[ 0.000000] Memory policy: Data cache writeback

[ 0.000000] CPU: All CPU(s) started in SVC mode.

[ 0.000000] random: get_random_bytes called from start_kernel+0x84/0x3c4 with crng_init=0

......

BusyBox v1.28.3 () built-in shell (ash)

_______ ________ __

| |.-----.-----.-----.| | | |.----.| |_

| - || _ | -__| || | | || _|| _|

|_______|| __|_____|__|__||________||__| |____|

|__| W I R E L E S S F R E E D O M

-----------------------------------------------------

OpenWrt SNAPSHOT, r6742-c71b8121ef

-----------------------------------------------------

=== WARNING! =====================================

There is no root password defined on this device!

Use the "passwd" command to set up a new password

in order to prevent unauthorized SSH logins.

--------------------------------------------------

root@OpenWrt:/#

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。