OpenWrt Forum Archive

Topic: How to only build the rootfs including jffs2 & generate related image

The content of this topic has been archived on 25 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi, Dear Friends,
As you know, with stable linux, we did not build the code of kernel every time. And we often modify our application in each package so as to modify the rootfs(or jffs2).
Therefore, could we only build the rootfs and not touch the kernel's code so as to save the building time?
Thanks in advance.

My current research:
#1. Checking the makefile: [Status: Fail]
  It seem the following commands can meet the requriment.

  make package/pkg-1/compile
  ...
  make package/pkg-n/compile
  make package/install
  make target/install  <-- However, the last install will include the compiling of kernel.

#2. Checking the Image Generator (Image Builder)  -- refer to http://wiki.openwrt.org/doc/howto/obtai … e.generate
The following example still cannot work.
  make image PROFILE=WL500GP PACKAGES="nano openvpn -ppp -ppp-mod-pppoe" FILES=files/

I would be interested in the same. I already have a working kernel and a working rootfs from somewhere else, and would like to combine the two into working factory/sysupgrade images.

Hi, Probono,
I cannot know the exact method to combine the two, but the following build log should be helpful. (please ignore my platform).

dd if=/media/home2/project/qsdk2/qsdk/build_dir/linux-ar71xx_generic/root.squashfs-64k bs=2818048 conv=sync; dd if=/media/home2/project/qsdk2/qsdk/build_dir/linux-ar71xx_generic/tmp/vmlinux-ap121-4M.uImage ) > /media/home2/project/qsdk2/qsdk/bin/ar71xx/openwrt-ar71xx-generic-ap121-4M-squashfs-sysupgrade.bin;

Hi xujie.paul, good idea to look at the log file. Which log file did you observe? It looks strange to me that the dd command before the ";" has no of=...

After one second I had posted a new topic, I saw this post. I think this is exactly what I want to know as well.
Hi probono, did you build the kernel and rootfs separately by using buildroot?
Is that possible to write them directly to the flash, if we could not find the way to combine them now?

(Last edited by stone8936 on 7 Apr 2014, 13:24)

Hi, thank xujie for the hint. I did not find the similar building logs as xuejie's, but found some other when I build firmware for tplink-tl-wdr3600/4300.

/home/xxx/openwrt/openwrt_12.09/openwrt/staging_dir/host/bin/lzma e /home/xxx/openwrt/openwrt_12.09/openwrt/build_dir/linux-ar71xx_generic/tmp/vmlinux-tl-wdr3600-v1 -lc1 -lp2 -pb2  /home/xxx/openwrt/openwrt_12.09/openwrt/build_dir/linux-ar71xx_generic/tmp/vmlinux-tl-wdr3600-v1.bin.lzma

/home/xxx/openwrt/openwrt_12.09/openwrt/staging_dir/host/bin/mktplinkfw -H 0x36000001 -W 1 -F 8Mlzma -N OpenWrt -V r39408  -k /home/xxx/openwrt/openwrt_12.09/openwrt/build_dir/linux-ar71xx_generic/tmp/vmlinux-tl-wdr3600-v1.bin.lzma -r /home/xxx/openwrt/openwrt_12.09/openwrt/build_dir/linux-ar71xx_generic/root.squashfs-raw -a 0x4 -j -o /home/xxx/openwrt/openwrt_12.09/openwrt/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr3600-v1-squashfs-factory.bin

/home/xxx/openwrt/openwrt_12.09/openwrt/staging_dir/host/bin/mktplinkfw -H 0x36000001 -W 1 -F 8Mlzma -N OpenWrt -V r39408  -s -k /home/xxx/openwrt/openwrt_12.09/openwrt/build_dir/linux-ar71xx_generic/tmp/vmlinux-tl-wdr3600-v1.bin.lzma -r /home/xxx/openwrt/openwrt_12.09/openwrt/build_dir/linux-ar71xx_generic/root.squashfs-raw -a 0x4 -j -o /home/xxx/openwrt/openwrt_12.09/openwrt/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr3600-v1-squashfs-sysupgrade.bin

I think the mktplinkfw does it for TP-LINK machine only.  When I build fw for another board, it uses openwrt/staging_dir/host/bin/mkmylofw. I managed combine a rootfs and a kernel into a usable firmware.

If you just want to build the rootfs, I think squashfs-tools is used. But according to the log, it probably need to use the tool padjffs2 to pad the rootfs, after creating root.squashfs and before combining.

/home/xxx/openwrt/openwrt_12.09/openwrt/staging_dir/host/bin/mksquashfs4 /home/xxx/openwrt/openwrt_12.09/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/root-ar71xx /home/xxx/openwrt/openwrt_12.09/openwrt/build_dir/linux-ar71xx_generic/root.squashfs -nopad -noappend -root-owned -comp xz -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2 -b 256k -processors 1
Parallel mksquashfs: Using 1 processor
Creating 4.0 filesystem on /home/xxx/openwrt/openwrt_12.09/openwrt/build_dir/linux-ar71xx_generic/root.squashfs, block size 262144.

However, I still want to know if there is a tool can do the reverse work, which detaches a firmware with kernel and rootfs.

(Last edited by stone8936 on 9 Jul 2015, 09:45)

probono wrote:

Hi xujie.paul, good idea to look at the log file. Which log file did you observe? It looks strange to me that the dd command before the ";" has no of=...

When you issue make target/linux/install V=s, buildroot will dump all processes to screen. There, you will find the line. If you append BUILD_LOG=1, then buildroot will create a log file.

mazilo wrote:
probono wrote:

Hi xujie.paul, good idea to look at the log file. Which log file did you observe? It looks strange to me that the dd command before the ";" has no of=...

When you issue make target/linux/install V=s, buildroot will dump all processes to screen. There, you will find the line. If you append BUILD_LOG=1, then buildroot will create a log file.

Thanks for mazilo debug method.  big_smile
We also enable the opinion in menuconfig as below.

CONFIG_BUILD_LOG:                                                       
                                                                     
 If enabled log files will be written to the ./log directory         
                                                                     
                                                                     
 Symbol: BUILD_LOG [=y]                                              
 Prompt: Enable log files during build process                       
   Defined at Config.in:525                                          
   Depends on: DEVEL [=y]                                            
   Location:                                                         
     -> Advanced configuration options (for developers) (DEVEL [=y]) 

And you will find there is a new folder named as logs which include all procedure regarding compile and install.

stone8936 wrote:

I think the mktplinkfw does it for TP-LINK machine only.  When I build fw for another board, it uses openwrt/staging_dir/host/bin/mkmylofw. I managed combine a rootfs and a kernel into a usable firmware.

If you just want to build the rootfs, I think squashfs-tools is used. But according to the log, it probably need to use the tool padjffs2 to pad the rootfs, after creating root.squashfs and before combining.

/home/zhaohan/openwrt/openwrt_12.09/openwrt/staging_dir/host/bin/mksquashfs4 /home/zhaohan/openwrt/openwrt_12.09/openwrt/build_dir/target-mips_r2_uClibc-0.9.33.2/root-ar71xx /home/zhaohan/openwrt/openwrt_12.09/openwrt/build_dir/linux-ar71xx_generic/root.squashfs -nopad -noappend -root-owned -comp xz -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2 -b 256k -processors 1
Parallel mksquashfs: Using 1 processor
Creating 4.0 filesystem on /home/zhaohan/openwrt/openwrt_12.09/openwrt/build_dir/linux-ar71xx_generic/root.squashfs, block size 262144.

However, I still want to know if there is a tool can do the reverse work, which detaches a firmware with kernel and rootfs.

Hi,stone8936, appreciate your findings.  However, I still didn't know how to generate alone the source of mksquashfs4 which includes the rootfs and jffs.

Hi xujie, I don't get your point. But once you have a file system tree (which is root-ar71xx in the log), you can generate a rootfs (root.squashfs in the log) using mksquashfs4. The mksquashfs4 is already in the buildroot.

For jffs2, I think you have to have root.squashfs generated beforehand, then use the tool padjffs2.

The discussion might have continued from here.