当前位置: 首页 > article >正文

Linux 移植_Home_Record

bin 文件各分区 起始地址和大小 

Linux 4.4

Linuy 6.8

## ubuntu24 服务器 ssh 登录被拒绝
https://blog.csdn.net/zao_chao/article/details/141646597

vim /etc/ssh/sshd_config,打开注释 #PermitRootLogin prohibit-password,并修改为

ListenAddress 0.0.0.0
PermitRootLogin yes


## ubuntu24 静态ip
https://blog.csdn.net/m0_73337964/article/details/139171729

      dhcp4: no
      addresses:
        - 192.168.3.50/24
      routes:
        - to: default
          via: 192.168.3.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 8.8.4.4

sudo netplan apply
sudo systemctl restart systemd-networkd
ip addr


Hi3516DV300-SDK 解压密码
www.mr-wu.cn 

=====================================================================================hi3798mv100 sdk 编译=====================================================================================
首先搭建虚拟机, 虚拟机选择ubunt x86, 就需要搭建交叉编译环境

arm-gcc 交叉编译环境搭建
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install g++-arm-linux-gnueabihf
arm-linux-gnueabihf-gcc -v


如果直接用hinas 编译,那么就是arm的环境


# hi3798mv100
https://hpzwl.blog.csdn.net/article/details/121314575

lzma --version | awk '$0~/LZMA.SDK.[0-9]\.[0-9]/{print $3}'


# 指定版本linux内核编译
cd /root/hi3798mv100/HiSTBLinuxV100R005C00SPC041B020 #(SDK_path)

"/root/hi3798mv100/HiSTBLinuxV100R005C00SPC041B020/source/kernel/linux-3.18.y/"

"/root/hi3798mv100/HiSTBLinuxV100R005C00SPC041B020/source/kernel/linux-3.18.y/arch/arm/configs/"


cp "/root/hi3798mv100/hi3798mv100_defconfig-0812" "/root/hi3798mv100/HiSTBLinuxV100R005C00SPC041B020/source/kernel/linux-3.18.y/arch/arm/configs/hi3798mv100_defconfig"


1. 先备份上面路径下的hi3798mv100_defconfig 原始文件

2. cd source/kernel/linux-3.18.y/

3. make ARCH=arm hi3798mv100_defconfig # Linux 内核编译选项

4. make ARCH=arm savedefconfig #重新生成defconfg文件,会在 上面的目录下生成deconfig 文件

5. cp defconfig arch/arm/configs/hi3798mv100_defconfig # 这一步可省略,如果用 hi3798mv100_defconfig-0812 文件,就不要拷贝

6. make distclean # 清理Linux内核的编译

7. cd $SDK_path;make linux #重新编译kernel


编译报错 yylloc
https://blog.csdn.net/zhoukaiqili/article/details/126191871



source ./env.sh  #SDK各种环境变量

make menuconfig
make build -j4 2>&1  | tee -a buildlog.txt

上面编译成功后,在out/hi3798mv100可以找到编译好的fastboot-burn.bin、bootargs.bin、hi_kernel.bin,分别是uboot引导文件、uboot引导参数配置和linux内核。


make cfg.mak clean #重新编译之前先clean
rm -r buildlog.txt


=====================================================================================Linux 6.8 内核 编译=====================================================================================

df -h

ln -s 源文件名 软连接文件名 #软链接 创建
ln -d 源文件名 硬连接文件名 #硬链接 创建

sudo passwd root # 启用root账户

ll -lh
ll -Sh
ll -rt

linux不像windows有个回收站,使用rm -rf *基本上文件是找不回来的

lsb_release -a
uname -r
uname -m
uname -a

cat /etc/lsb-release # 查看发行版本
cat /proc/version    # 查看内核编译信息
getconf LONG_BIT     # 32/64bit

lscpu

nproc 处理器核数查看

# gitlab 服务器配置

https://www.cnblogs.com/chenfulin5/p/8289146.html

https://blog.csdn.net/m0_63230155/article/details/131952266


sudo apt-get install curl openssh-server ca-certificates postfix

升级git

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
add-apt-repository ppa:git-core/ppa
sudo apt-get install git



# Boot Loader

芯片出厂时(FT 测试)内部会固化ROM(烧录操作),固化ROM作用基本上是引导Boot Loader

在CPU刚上电启动的时候,一般连内存控制器都没有配置过,根本无法在内存中运行程序,更不可能处在Linux内核的启动环境中。为了初始 化CPU及其他外设,使得Linux内核可以在系统主存中跑起来,并让系统符合Linux内核启动的必备条件,必须要有一个先于内核运行的程序,他就是所 谓的引导加载程序(Boot Loader)。
而Boot Loader并不是Linux才需要,是几乎所有的运行操作系统的设备都具备的.

Boot Loader是在操作系统内核运行之前运行的一段小程序。通过这段小程序,我们可以初始化硬件设备,从而将系统的软硬件环境带到一个合适的状态,以便为最终调用操作系统内核准备好正确的环境,最后从别处(Flash、以太网、UART)载入内核映像并跳到入口地址.

由于BootLoader直接操 作硬件,所以她严重依赖于硬件。
嵌入式世界中建立一个通用的 BootLoader 几乎是不可能的,而有可能的是让一个 Boot Loader代码支持多种不同的构架和操作系统,并让她方便移植。
U-boot就是支持多平台多操作系统的一个杰出代表.


# U-Boot

U-Boot是Das U-Boot的简称,其含义是Universal Boot Loader,是遵循GPL条款的开放源码项目。
U-Boot作为一个主流、通 用的Bootloader,成功地被移植到包括主流的PowerPC、ARM、X86 、MIPS、NIOS、XScale等体系结构的上百种开发板,成为功能最多、灵活性最强,并且开发最积极的开源BootLoader

Linux 启动需要一个 bootloader 程序,上电后先运行bootloader,因为 linux 是运行在DDR里面的,bootloader 程序会先初始化DDR等外设,一般 linux 镜像zimage(uimage)+设备树(.tdb文件)存放到外置存储区(SPI_flash、SD、EMMC、NAND等),然后将Linux内核(镜像)从flash,拷贝到 DDR 中,再去启动。


http://blog.chinaunix.net/uid-23028407-id-3027518.html

## uboot 加载内核
https://www.cnblogs.com/chenfulin5/p/6937334.html


## uboot 编译
https://github.com/u-boot/u-boot/tags
https://docs.u-boot.org/en/latest/

https://www.cnblogs.com/jzcn/p/14888394.html



=====================================================================================uboot 编译 on hinas arm-gcc9 Compile=================================================================================


====================================================先配置 .config, 然后执行make 自动编译uboot====================================================
.config 用来配置那些文件或者目录被编译,会有对应的.h 文件 或.c 文件被


#uboot默认配置编译
uboot 配置完成后(使用defconfig),会生成 .config 文件 (配置项 = y 或者 is not set)

#uboot 手动配置编译
make menuconfig # 早期的uboot 不支持这种方式,linux 内核编译使用的这种方式,uboot逐渐靠近linux,因此就使用menuconfig 方式

```
# 执行上面的命令报下面的错,依赖问题 sudo apt install libncurses-dev 
* Unable to find the ncurses package.
* Install ncurses (ncurses-devel or libncurses-dev
* depending on your distribution).
*
make[1]: *** [scripts/kconfig/Makefile:227: scripts/kconfig/.mconf-cfg] Error 1
make: *** [Makefile:586: menuconfig] Error 2

 #### make target "menuconfig" failed !!! ####


```


====================================================执行make 自动编译uboo

make CC=arm-linux-gnueabihf-gcc-4.9.4

sudo apt install swig

``` 
error: command 'swig' failed: No such file or directory
make[2]: *** [scripts/dtc/pylibfdt/Makefile:33: rebuild] Error 1
make[1]: *** [scripts/Makefile.build:397: scripts/dtc/pylibfdt] Error 2
make: *** [Makefile:2055: scripts_dtc] Error 2

 #### make target "" failed !!!(19 seconds) ####
```



sudo apt install python3.12-dev # Python 大版本

```
scripts/dtc/pylibfdt/libfdt_wrap.c:177:11: fatal error: Python.h: No such file or directory
  177 | # include <Python.h>
      |           ^~~~~~~~~~

```



sudo apt-get install libssl-dev

```
include/image.h:1472:12: fatal error: openssl/evp.h: No such file or directory
 1472 | #  include <openssl/evp.h>
      |            ^~~~~~~~~~~~~~~

```



===========================================================编译uboot 自带的defconfig 芯片,可以===========================================================
make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- imx6ul_geam_mmc_defconfig -j 2
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j 2 



sudo apt-get install uuid-dev
```
 tools/mkeficapsule.c:19:10: fatal error: uuid/uuid.h: No such file or directory    19 | #include <uuid/uuid.h>
```


sudo apt-get install libgnutls28-dev
```
tools/mkeficapsule.c:21:10: fatal error: gnutls/gnutls.h: No such file or directory
   21 | #include <gnutls/gnutls.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
```


./arch/arm/include/asm/bitops.h:18:

#ifndef __LINUX_ARM_ARCH__
#define __LINUX_ARM_ARCH__ 0
#endif

```
./arch/arm/include/asm/bitops.h:18:24: error: operator '<' has no left operand
   18 | #if __LINUX_ARM_ARCH__ < 5
```


====================================================hi3798mv100_defconfig + uboot官方源码 uboot 2024,histb-mainline_u-boot,HiSTB-Uboot-master 都无发正常编译出hi3798mv100 uboot.bin,只有 hisdk 才可以编译出====================================================

make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hi3798mv100_defconfig -j 2

make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- -j 2 

STANDALONE_LOAD_ADDR = 0xc100000

1. only uboot
cd /home/uboot/HiSTB-Uboot-master/
cp .reg

make distclean

./include/linux/compiler-gcc4.h >> compiler-gcc9.h # rename

make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hi3798mx -j 4





cd histb-mainline_u-boot/
make distclean


make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hi3798mv100_defconfig -j 4


2. hisi sdk
cd /home/hisi_sdk/HiSTBLinuxV100R005C00SPC060
make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hiboot -j 4



3.uboot 2024
make distclean
make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hi3798mv100_defconfig -j 4



=====================================================================================uboot 编译 on ubut24 arm-gcc13 Compile================================================================================

1. only uboot
cd /home/uboot/HiSTB-Uboot-master/
cp .reg

make distclean

cp /home/uboot/HiSTB-Uboot-master/include/linux/compiler-gcc4.h /home/uboot/HiSTB-Uboot-master/include/linux/compiler-gcc13.h #因为编译器版本原因

/home/uboot/HiSTB-Uboot-master/arch/arm/lib/board.c: inline 不能使用weak,去掉inline


# 注释掉CONFIG_PRODUCT_WITH_BOOT 这一行 product_init fastapp_entry
include/configs/hi3798mx_config.h:85:#define CONFIG_PRODUCT_WITH_BOOT   y 


make ARCH=arm CC=arm-linux-gnueabihf-gcc-4.9.4 CROSS_COMPILE=arm-linux-gnueabihf- hi3798mx -j 2 #如果没有指定编译器为4.9,导致浮点编译问题

make ARCH=arm march=armv7-a+nofp mfloat-abi=soft CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hi3798mx -j 2 



cd histb-mainline_u-boot/
make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hi3798mv100_defconfig -j 2


2. hisi sdk
cd /home/hisi_sdk/HiSTBLinuxV100R005C00SPC060


.PHONY: build clean
clean:
.PHONY: signature signature_clean
signature_clean:
.PHONY: tools  tools_clean
tools_clean:
        $(AT)make -C $(HI_TOOLS_DIR) clean
.PHONY:  hiboot  hiboot_clean  advca_programmer
hiboot_clean:
        $(AT)make -C $(BOOT_DIR) clean $(if $(HI_OUT_DIR),O=$(HI_OUT_DIR)/obj/source/boot,)
.PHONY:  linux linux_clean
linux_clean:
        $(AT)make -C $(KERNEL_DIR) clean
.PHONY:  rootfs  rootfs_clean
rootfs_clean:
        $(AT)make -C $(ROOTFS_SRC_DIR) clean
.PHONY:  common common_clean
common_clean:
        $(AT)make -C $(COMMON_DIR)/api clean
.PHONY:  msp  msp_clean
msp_clean:
        $(AT)make -C $(MSP_DIR)/api clean
.PHONY:  higo  higo_clean
higo_clean:
        $(AT)make -C $(MSP_DIR)/api/higo clean
.PHONY:  omx  omx_clean
omx_clean:
        $(AT)make -C $(MSP_DIR)/api/omx clean
.PHONY:  gpu  gpu_clean
gpu_clean:
        $(AT)make -C $(MSP_DIR)/api/gpu clean
.PHONY:  component  component_clean
component_clean:
        $(AT)make -C $(COMPONENT_DIR) clean
.PHONY: tee tee_clean
tee_clean:
        $(AT)[ ! -d $(HI_TEE_OS_DIR) ] || make -C $(HI_TEE_OS_DIR) clean
.PHONY:  sample  sample_clean
sample_clean:
        $(AT)make -C $(SAMPLE_DIR) clean
.PHONY:  rootbox  rootbox_clean
rootbox_clean:
        $(AT)make -C $(COMPONENT_DIR)/qt clean
dfb_clean:
        $(AT)make -C $(COMPONENT_DIR)/directfb clean
        $(AT)make -C $(COMPONENT_DIR) loader_clean


## hiboot hiboot_clean
make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hiboot_clean -j 2


make ARCH=arm CC=arm-linux-gnueabihf-gcc-4.9.4 CROSS_COMPILE=arm-linux-gnueabihf- hiboot -j 2

# 下面版本太高,编译报错
make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hiboot -j 2 # 13.2

make ARCH=arm CC=arm-none-linux-gnueabihf-gcc-10.3.1 CROSS_COMPILE=arm-linux-gnueabihf- hiboot -j 2

make ARCH=arm CC=arm-none-linux-gnueabihf-gcc-11.2.1 CROSS_COMPILE=arm-linux-gnueabihf- hiboot -j 2



## hilinux
make ARCH=arm CC=arm-linux-gnueabihf-gcc-4.9.4 CROSS_COMPILE=arm-linux-gnueabihf- linux -j 2



Fastboot 3.3.0-dirty (root@) (Oct 19 2024 - 17:44:01)

vim out/hi3798mv100/hi3798mdmo1g/obj/source/boot/fastboot/include/version_autogenerated.h

vim /home/hisi_sdk/HiSTBLinuxV100R005C00SPC060/source/boot/fastboot/Makefile

$(VERSION_FILE):
                @( printf '#define U_BOOT_VERSION "Fastboot %s%s"\n' "$(U_BOOT_VERSION)" \
                 '$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ) > $@.tmp
                @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@

$(TIMESTAMP_FILE):
                @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@
                @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@


3.uboot 2024
make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hi3798mv100_defconfig -j 2



Booting kernel from Legacy Image at 01ffffc0

UART BASE ADDR 0xF8B00000

zreladdr-y	:= 0x00008000
params_phys-y	:= 0x00000100
initrd_phys-y	:= 0x00800000
LOADADDR	:= 0x02000000




# arm 官方的编译链 
https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads/11-2-2022-02 # 最新版
https://developer.arm.com/downloads/-/gnu-a #历史版本1
https://releases.linaro.org/components/toolchain/binaries/ #历史版本2


# gcc
ls /usr/bin/gcc*
export PATH=$PATH:/usr/bin/x86_64-linux-gnu-gcc-9 # 最后添加这一句

sudo apt-get remove --auto-remove gcc
sudo apt-get install gcc
sudo apt-get install gcc-9
gcc -v #


ln -s gcc gcc-9
ln -s


ll /usr/bin/ | grep gcc

rm -r /usr/bin/gcc;rm -r /usr/bin/gcc-ar;rm -r /usr/bin/gcc-nm;rm -r /usr/bin/gcc-ranlib;


cp /usr/bin/arm-linux-gnueabihf-gcc /usr/bin/gcc;
cp /usr/bin/arm-linux-gnueabihf-gcc-ar /usr/bin/gcc-ar;
cp /usr/bin/arm-linux-gnueabihf-gcc-nm /usr/bin/gcc-nm;
cp /usr/bin/arm-linux-gnueabihf-gcc-ranlib /usr/bin/gcc-ranlib;



ln -s /usr/bin/gcc  /usr/bin/arm-linux-gnueabihf-gcc-13;
ln -s /usr/bin/gcc-ar /usr/bin/arm-linux-gnueabihf-gcc-ar-13;
ln -s /usr/bin/gcc-nm /usr/bin/arm-linux-gnueabihf-gcc-nm-13;
ln -s /usr/bin/gcc-ranlib /usr/bin/arm-linux-gnueabihf-gcc-ranlib-13;


ln -s /usr/bin/gcc  /usr/bin/gcc-13;
ln -s /usr/bin/gcc-ar /usr/bin/gcc-ar-13;
ln -s /usr/bin/gcc-nm /usr/bin/gcc-nm-13;
ln -s /usr/bin/gcc-ranlib /usr/bin/gcc-ranlib-13;


# 安装gcc-arm-linux-gnueabihf,注意不是arm-linux-gnueabihf-gcc
sudo apt-get install arm-linux-gnueabihf-gcc # 这是错误的
sudo apt-get install gcc-arm-linux-gnueabihf
arm-linux-gnueabihf-gcc -v


# 卸载gcc-arm-linux-gnueabihf
sudo apt remove --auto-remove gcc-arm-linux-gnueabihf
sudo apt autoremove

whereis arm-linux-gnueabihf-gcc
which arm-linux-gnueabihf-gcc


# 安装gcc-arm-none-eabi,不支持操作系统编译

sudo apt-get remove --auto-remove gcc-arm-none-eabi
sudo apt-get install gcc-arm-none-eabi
arm-none-eabi-gcc -v



du -sh /home/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/
785M    /home/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/

du -sh /home/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf/
486M    /home/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf/

du -sh /home/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/
3.0G    /home/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/

du -sh /home/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/
494M    /home/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/



# 安装gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf/
tar -xvf gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.xz #解压



vim /etc/profile

export PATH=$PATH:/home/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf/bin # 最后添加这一句
export PATH=$PATH:/home/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gcc-11.2.1
export PATH=$PATH:/home/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-gcc-10.3.1
export PATH=$PATH:/home/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc-4.9.4
export PATH=$PATH:/home/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc-11.2.1

source /etc/profile


arm-none-linux-gnueabihf-gcc -v
arm-none-linux-gnueabihf-gcc-11.2.1 -v
arm-none-linux-gnueabihf-gcc-10.3.1 -v
arm-linux-gnueabihf-gcc-4.9.4 -v
arm-none-eabi-gcc-11.2.1 -v




make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig #menuconfig 配置后的结果将会保存在对应模块根目录下的 .config 文件中

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- hi3798mv100_defconfig

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- huawei_hg556a_ram_defconfig

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j2

sudo make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hi3798mv100_defconfig V=1 -p > all.log

sudo make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hsdk_4xd_defconfig V=1 -p > all.log
sudo make ARCH=arm CC=arm-linux-gnueabihf-gcc CROSS_COMPILE=arm-linux-gnueabihf- hsdk_defconfig V=1 -p > all.log





Nand falsh 在 u-boot 里面,是可以执行擦除操作
nand erase.chip
nand erase.spread 0x0 0x780000



# Linux 6.8 内核 编译

Ubuntu 24.04 LTS 采用 Linux 6.8 内核

Linux内核 :Linux内核 :是系统的心脏,是运行程序和管理像磁盘和打印机等硬件设备的核心程序,它提供了一个在裸设备与应用程序间的抽象层。

Linux 内核的主要模块(或组件)分以下几个部分:进程管理子系统、内存管理子系统、文件子系统、网络子系统、设备子系统等


Linux发行版:它是一个可以高效使用Linux 内核的操作系统,即它涵盖了Linux内核,此外还包含一些GNU程序库和工具,命令行shell,图形界面的X Window系统和相应的桌面环境,如KDE或GNOME,并包含数千种从办公套件,编译器,文本编辑器到科学工具的应用软件。典型的有CentOS、Ubuntu、RedHat、SUSE等。


https://linux.cn/article-16252-1.html

对于Linux内核,编译可以生成不同格式的映像文件, 几种linux内核文件的区别:

zImage是ARM Linux常用的一种压缩映像文件,
uImage是U-boot专用的映像文件,它是在zImage之前加上一个长度为0x40的“头”,说明这个映像文件的类型、加载位置、生成时间、大小等信息。换句话说,如果直接从uImage的0x40位置开始执行,zImage和uImage没有任何区别

1、vmlinux  编译出来的最原始的内核文件,未压缩。

2、zImage   是vmlinux经过gzip压缩后的文件。

3、bzImage bz表示“big zImage”,不是用bzip2压缩的。两者的不同之处在于,zImage解压缩内核到低端内存(第一个640K),bzImage解压缩内核到高端内存(1M以上)。如果内核比较小,那么采用zImage或bzImage都行,如果比较大应该用bzImage。

4、uImage   U-boot专用的映像文件,它是在zImage之前加上一个长度为0x40的tag。

5、vmlinuz  是bzImage/zImage文件的拷贝或指向bzImage/zImage的链接。

6、initrd   是“initial ramdisk”的简写。一般被用来临时的引导硬件到实际内核vmlinuz能够接管并继续引导的状态。



=====================================================================================x86 Ubuntu 编译内核=====================================================================================


# ubuntu(20.04)+linux内核(5.17.3)编译内核
https://blog.csdn.net/weixin_62882080/article/details/124260136

1. 下载源码

编译依赖包
sudo apt-get install libncurses5-dev 
sudo apt-get install build-essential
sudo apt-get install libssl-dev
sudo apt-get install openssl
sudo apt-get install pkg-config
sudo apt-get install libc6-dev
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install libelf-dev
sudo apt-get install zlibc
sudo apt-get install minizip
sudo apt-get install libidn11-dev 
sudo apt-get install libidn11
sudo apt-get install ncurses #ncurses 库是字符终端下屏幕控制的基本库


2. 
tar -xzvf linux-6.8-rc6.tar.gz
cd linux-6.8-rc6 #进入源码目录


3. 正式编译
make mrproper 

cp /boot/config-`uname -r`  ./.config
make menuconfig

make O=./0_build_out bzImage -j2
make CC=/usr/bin/gcc-9 bzImage -j2



编译过程中报下面的错,是因为内存不够导致的
gcc: fatal error: Killed signal terminated program cc1
compilation terminated.
make[4]: *** [scripts/Makefile.build:243: arch/x86/xen/setup.o] Error 1
make[3]: *** [scripts/Makefile.build:481: arch/x86/xen] Error 2
make[2]: *** [scripts/Makefile.build:481: arch/x86] Error 2


sudo swapoff -a

sudo dd if=/dev/zero of=/swapfile bs=1M count=512
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
/swapfile swap swap defaults 0 0

# 查看交换区
sudo swapon --show
sudo free -h



sudo apt install gcc-9 g++-9
https://wenku.csdn.net/answer/1aa5310fdf4b448e85f5e27eb73227c2

=====================================================================================Arm Ubuntu 编译内核=====================================================================================


https://github.com/Tvirus/hisi_temp_monitor
https://github.com/1010littlestar
https://github.com/hisilicon
https://www.cnblogs.com/xingboy/category/2023185.html
https://gitee.com/Embedfire-imx6/ebf_6ull_document_pdf



1. 下载源码

编译依赖包
sudo apt-get install libncurses5-dev 
sudo apt-get install build-essential
sudo apt-get install libssl-dev
sudo apt-get install openssl
sudo apt-get install pkg-config
sudo apt-get install libc6-dev
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install libelf-dev
sudo apt-get install zlibc
sudo apt-get install minizip
sudo apt-get install libidn11-dev 
sudo apt-get install libidn11
sudo apt-get install ncurses #ncurses 库是字符终端下屏幕控制的基本库

2. 
tar -xzvf linux-6.8-rc6.tar.gz
cd linux-6.8-rc6 #进入源码目录

3. 
这里用盒子来编译,boot里没有配置文件,就重新从hi3798 sdk里 arch/arm/configs copy一个 hi3798mv100_defconfig
copy hi3798mv100的config
cp -v /boot/config-$(uname -r) .config

4.
sudo apt install libncurses-dev

make menuconfig 编译报错 scripts/kconfig/lexer.lex.c 找不到,需要安装下面的库
https://blog.csdn.net/u010835747/article/details/118282135

sudo apt-get install flex
sudo apt-get install bison

https://www.cnblogs.com/xingboy/p/16478998.html

make menuconfig # 选择编译的模块 默认选择当前目录下的 .config

make menuconfig KCONFIG_CONFIG=arch/arm/configs/hi3798mv100_defconfig ARCH=arm # 指定目录下的config
执行完上面后,会进入menu kconfig 界面,保存为 ./0_build_output/.config


# 保存 defconfig 文件, 这一步不是必须的

make savedefconfig ARCH=arm


# 覆盖原来的配置文件,注意提前备份原始的config 文件
cp defconfig arch/arm/configs/hi3798mv100_defconfig

5.
https://blog.csdn.net/Mculover666/article/details/126160621

make O=./0_build_output -j$(nproc) 2>&1 | tee ./0_build_output/build_log
make O=./0_build_output -j4 2>&1 | tee ./0_build_output/build_log


编译报错 /bin/sh: 1: bc: not found, 缺少bc 库
sudo apt-get install bc



# 编译 输出到指定文件夹
rm -r 0_build_output/
mkdir 0_build_output
OUTPUT_PATH=${PWD}/0_build_output

make mrproper # 重复编译前 需要执行,第一次可忽略

cp -v arch/arm/configs/hi3798mv100_defconfig ${OUTPUT_PATH}/.config

make menuconfig O=${OUTPUT_PATH} ARCH=arm

cd 0_build_output/;make savedefconfig ARCH=arm

make O=${OUTPUT_PATH} all -j4


编译完了会在相应的目录生成zImage 映像文件, 比如说arm 架构的就是arch/arm/boot/zImage 文件.
编译输出文件加介绍

arch        : 与平台架构相关的目录

drivers    : 设备驱动程序相关目录

fs    : 各种支持的文件系统 , 如ext , fat 等

include   : 头文件相关的目录 , 其中 , 和系统相关的头文件在 include/linux 中 , 如果你想学内核 , 入门级别便是把这个头文件搞熟练

init     : 内核初始化代码 (注意不是系统引导代码)

ipc     : 进程间通信代码

kernel  : 内核的最核心部分 , 包括进程调度 , 定时器 ,  和平台相关的一部分代码在 arch/*/kernel 当中

lib   : 库文件代码

mm   : 内存管理相关代码

net    : 网络相关代码 , 实现了各种常见的网络协议

scripts : 编译内核所用的脚本

security : 主要是一个SElinux 的模块

sound : 常用的音频设备的驱动程序等

usr   : 早期用户空间代码












---------------------  make help ----------------------
input 'q' to exit .

OVERVIEW:
    When the first time you get the SDK, please use the 'make build' command 
to build it.
    After build the SDK. You can make the SDK use the 'make all' and 'make install'
command to compile and install your modifies, or use the 'make clean' and 'make 
install' command to clean and make the SDK.
    If you modify some code of SDK, you can use the command list below to compile 
them respectively. If unsure, use 'make rebuild' command to rebuild the whole SDK.

    This document list the command you can use.     

make:
	The same as make help.

make help:
	Show this list.

make tools:
	Make tools, you need this command when you make the SDK first time. 
	Recommend to use 'make tools_install' directly.
	  
make tools_clean:
	Clean tools.
	
make tools_install:
	Install tools. Rely on tools.
	
make tools_uninstall:
	Uninstall tools.

make defconfig:
	Create the default SDK config file(cfg.mak).
	You can indicate your config file by CFILE parameter:
	make defconfig CFILE=$(YOUR_CONFIG_FILE)

make menuconfig:
	Configurate the SDK, the results will be saved to cfg.mak.

make prepare:
	Prepare for build.

make build:
	Make prepare, all and install.
	
make distclean:
	Clean all.

make rebuild:
	Clean all, then build again.
	
make all:
	Will make hiboot, linux, rootfs, common, msp and component.

make clean:
	Will clean hiboot, linux, rootfs, common, msp and component.
	
make install:
	Will install hiboot, linux, rootfs, common, msp, component, rootbox,
	then create filesystem image, make sample lastly.

make uninstall:
	Will uninstall hiboot, linux, rootfs, common, msp and component.

make XXX:
	The XXX can be hiboot, linux, rootfs, common, msp, component or sample, 
	make them respectively.

make XXX_clean:
	The XXX can be hiboot, linux, rootfs, common, msp, component or sample, 
	clean them respectively.
	
make XXX_install:
	The XXX can be hiboot, linux, rootfs, common, msp or component, 
	install them respectively.

make XXX_uninstall:
	The XXX can be hiboot, linux, rootfs, common, msp or component,
	uninstall them respectively.

make rootbox_install:
	Install rootbox.
	
make fs:
	Create filesystem images.

Sub modules of msp, component and sample can be make respectively, their commond:
	make XXX M=MODULE_NAME
	make XXX_clean M=MODULE_NAME
	make XXX_install M=MODULE_NAME
	make XXX_uninstall M=MODULE_NAME
Examples:
	make msp M=i2c
	make sample M=esplay
	
You can compile in every directory which includes a Makefile, for example, you can use
	make sample M=esplay
in ${SDK_DIR}, or use
	make esplay
in ${SDK_DIR}/sample, or use
	make
in ${SDK_DIR}/sample/esplay.


http://www.kler.cn/news/363959.html

相关文章:

  • PHP企业门店订货通进销存系统小程序源码
  • CZX前端秘籍3
  • 骨传导耳机哪个品牌好?2024年五大热门精选骨传导耳机推荐
  • 解锁文本数据可视化的无限可能:Wordcloud库全解析
  • 易控天地|易控天地标准版3.0(EconTNT STD3.0)安装记录
  • PostGis空间(下):空间连接与空间索引
  • 【Linux系统】缺页中断机制
  • springboot餐厅点餐系统
  • hi3536上ffmpeg带rtmp移植
  • 【C++复习】经典笔试题
  • 【Linux系统内核探索】进程调度
  • 【设计模式】Liskov替换原则
  • 智谱清言AI
  • Java | Leetcode Java题解之第497题非重叠矩形中的随机点
  • Spring AOP的概念与使用
  • 构建后端为etcd的CoreDNS的容器集群(一)、生成自签名证书
  • java的maven打包插件来了,package一键打包exe、dmg、rpm等
  • 小程序开发语言Java跟php的区别
  • Element Plus的el-tree-v2 组件实现仅叶子节点显示勾选框,并且只能单选
  • MYSQL-SQL-04-DCL(Data Control Language,数据控制语言)
  • 若依框架vue3模板
  • 单例模式是一种常见的设计模式,确保一个类只有一个实例,并提供一个全局访问点。
  • Linux Redis查询key与移除日常操作
  • 尚硅谷redis 第97节 redisTmplate下答疑
  • 代码随想录算法训练营第二天| 209.长度最小的子数组 59.螺旋矩阵II 区间和 开发商购买土地
  • 身份证识别JAVA+OPENCV+OCR