Unable to generate Sysupgrade.bin and partition structure

Source: Internet
Author: User

1. Make Menuconfig post-compilation does not generate Openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-sysupgrade.bin because the image is beyond the size of the flash definition, The actual flash is 8M, compile 703N without modifying the configuration compiled into 4M, modify the following two files (trunk version)

1.

VI tools/firmware-utils/src/mktplinkfw.c

. id = "TL-WR703NV1",
. hw_id = HWID_TL_WR703N_V1,
. Hw_rev = 1,
. layout_id = "4Mlzma",//Change 4Mlza to 8Mlzma save.

2.

VI Target/linux/ar71xx/image/makefile

Define Device/tl-wr703n-v1
$ (DEVICE/TPLINK-8MLZMA)//modify 4mIzma to 8mIzma
Boardname: = tl-wr703n
Device_profile: = TLWR703
Tplink_hwid: = 0x07030101
CONSOLE: = ttyath0,115200
Endef

System structure

In the previous chapter we have completed the brush work, this time the system was first launched, and formatted its "writable" partition. So how does partitioning happen in the device? The first thing we need to know is that the OPENWRT partition under different processors is slightly distinguishable, not all partitions are identical. On the router's flash, the driver used in the kernel is the MTD device driver.

MTD (Memory technology Devices, RAM technology device) is a Linux drive subsystem for accessing memory class devices (ROM, FLASH). Its main purpose is to make the Flash class device more accessible, so it provides an abstract interface between the hardware and the upper layer, so that under the operating system we can operate the device like a hard disk. A friend who has looked closely at Linux startup information will see this passage:

[0.690000] 5 tp-link partitions found on MTD device spi0.0
[0.700000] Creating 5 MTD partitions on "spi0.0":
[0.700000] 0x000000000000-0x000000020000: "U-boot"
[0.710000] 0x000000020000-0x00000012a290: "Kernel"
[0.730000] 0x00000012a290-0x0000007f0000: "Rootfs"
[0.760000] 0x000000300000-0x0000007f0000: "Rootfs_data"
[0.760000] 0x0000007f0000-0x000000800000: "Art"
[0.770000] 0x000000020000-0x0000007f0000: "Firmware"

This information represents the flash partition that is recognized by the current system. We can use the computer calculator to calculate, open the calculator, select Scientific, hexadecimal, enter the partition capacity named Art (800000-7f0000) result is 10000 (hex), this time click on the decimal, the system will automatically convert the results to decimal, Divided by 1024, the result is a scale (K) indicating that the partition capacity is 64k. In the OpenWrt system, the Atheros scheme is now implemented to automatically find the end of the partition.

On the above several partitions, let me explain the following (partition name, partition capacity, Partition Function):

    • "U-boot": 128KB, Device initialization program + bootloader code itself
    • "Kernel": 1MB, storage System kernel binary code, according to x86 is the raw partition, that is, there is only the kernel binary, there is no file system.
    • "Rootfs": 6.7MB, Full system file contains read-only and writable
    • "Rootfs_data": 4.9MB, the position of the writable part in the Rootfs
    • "Art": 64kb,eeprom partition, in the Atheros scenario, this partition holds the wireless hardware parameters
    • "Firmware": 7.9MB, Full firmware location contains everything except "U-boot" and "Art"

Did you see the faint? Here, I'll draw a simple diagram for you to see:

This is its partitioning logic. Please do not care too much about this place, a little dizzy also does not matter, continue to look back, this place left behind slowly understand.

In the system, you can perform the following instructions to view the current system partition:

The location of each partition in Flash is/dev/mtdblockx such as you want to read the data in the art section and then execute:

Then execute hexdump-c/tmp/1 to see the contents of this partition.

File structure of the system

Well, this section of ours will be very important. The previous section said that the system will format "writable Partition" at the first boot, what is the logical relationship?

    1. First Uboot starts the kernel is completed, the "ROM Partition" is loaded by the kernel (that is, Rootfs minus rootfs_data to get the partition)
    2. The ROM partition uses the SQUASHFS file system (a compressed read-only file system) supported by the Linux kernel and mounts it to the/rom directory (also mounted as the root file system) when it is loaded.
    3. The system will use the JFFS2 file system to format this part of the Rootfs_data and mount this part to the/overlay directory.
    4. The/overlay is transparently mounted AS/partition.
    5. Mount a portion of the memory as the/tmp directory.

This time we must have a question: What is the root file system? This is a openwrt design advantage, it uses a kind of called overlay transparent mount technology, first mount the/rom as/root file, and then with/overlay overlay on/above, so that when you make the file system changes, changes, the operation will be recorded in the overlay. ROM is not changed. And the simplest way to restore the factory settings is to delete all files under/overlay.

In general, the system's start-up process is similar to the distribution under x86 such as CentOS. As the reader of this article is familiar with the Linux friends, about the system's start-up process does not do a detailed explanation.

Unable to generate Sysupgrade.bin and partition structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.