Category:Linux SDK
Structure
- 上电 ——> Bootloader —[传递参数]—> 加载内核 ——> 内核挂载根文件系统 ——>执行应用程序
Example SPI Flash Partition
分区序号 | 分区大小 | 分区作用 | 地址空间及分区名 |
---|---|---|---|
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” |
Nano F1C100S - https://whycan.cn/t_2179.html
ID SIZE USAGE ADDR 0 448kb U-boot 0x0000 0000 - 0x0007 0000 1 64kb dtb 0x0007 0000 - 0x0008 0000 2 4mb kernel 0x0008 0000 - 0x0048 0000 3 7.5mb rootfs 0x0048 0000 - 0x00c0 0000 4 4mb overlay 0x00c0 0000 - 0x0100 0000
- Structure 2
- 0x0 u-boot
- 0x40000 dtb -> device tree
- 0x50000 kernel -> kernel
- 0x510000 rootfs -> root file system
Pack Image Firmware
二进制bin 打包 Zero V3S
以16M 大小flash镜像打包脚本为例:
dd if=/dev/zero of=flashimg.bin bs=1M count=16 &&\ dd if=$YOUR_UBOOT_FILE of=flashimg.bin bs=1K conv=notrunc &&\ dd if=$YOUR_DTB_FILE of=flashimg.bin bs=1K seek=1024 conv=notrunc &&\ dd if=$YOUR_KERNEL_FILE of=flashimg.bin bs=1K seek=1088 conv=notrunc &&\ mkdir rootfs tar -xzvf $YOUR_ROOTFS_FILE -C ./rootfs &&\ cp -r $YOUR_MOD_FILE rootfs/lib/modules/ &&\ # 为根文件系统制作jffs2镜像包 # --pad参数指定 jffs2大小 # 由此计算得到 0x1000000(16M)-0x10000(64K)-0x100000(1M)-0x400000(4M)=0xAF0000 mkfs.jffs2 -s 0x100 -e 0x10000 --pad=0xAF0000 -d rootfs/ -o jffs2.img &&\ dd if=jffs2.img of=$YOUR_IMG_FILE bs=1K seek=5184 conv=notrunc &&\
以上脚本通过对一个生成的16M空bin文件填充 uboot、dtb、kernel、rootfs 生成 16M 镜像,如需修改,请注意各个文件的大小,修改成对应地址(注意对齐)。
至此,SPI系统各部分已编译完成,通过sunxi-fel进行烧写即可;
Debug - Segment Fault
Core Dump
Toolchain Setup
Pre install
- sudo apt install build-essential checkinstall zlib1g-dev libssl-dev flex bison libncurses5-dev -y
Buildroot
- apt-get install linux-headers-$(uname -r)
Toolchain
- Install ARM GCC
Normal on PC
- gcc: gcc -o helloword helloword.c
Openwrt
- openwrt compiler: /openwrt/staging_dir/toolchain_mispel_...../bin/mispel-openwrt-linux-gcc -o helloword hellworld.c
- to fix error - environment error'STAGING_DIR'not defined, run - export STAGING_DIR=/openwrt/staging_dir/
- to set openwrt complier absoulte directory run - nano /etc/environment, add directory path after ":", run - source environment to make it work, finall command will be mispel-openwrt-linux-gcc
Reference
- USB Gadget - https://linux-sunxi.org/USB_Gadget
- Reference - https://www.thirtythreeforty.net/posts/2019/12/my-business-card-runs-linux/
- Starting linux - https://www.cnblogs.com/schips/p/11393234.html
LPI
Full process Zero V3S
Subcategories
This category has the following 6 subcategories, out of 6 total.