Step 7 : Post Build Checks

  • In this program, you are going to learn

  • How to ?

Topics in this section,

$ cd $HOME/openwrt/build_dir/target-aarch64_cortex-a72_musl/linux-bcm27xx_bcm2711/linux-6.1.69

$ cat .config
$ cd $HOME/openwrt/staging_dir/toolchain-aarch64_cortex-a72_gcc-12.3.0_musl/aarch64-openwrt-linux-musl/bin

$ ls -l bin

-rwxr-xr-x 2 test 2226840 Dec 23 02:58 ar
-rwxr-xr-x 2 test 3467944 Dec 23 02:58 as
-rwxr-xr-x 4 test 4025768 Dec 23 02:58 ld
-rwxr-xr-x 4 test 4025768 Dec 23 02:58 ld.bfd
-rwxr-xr-x 2 test 2217128 Dec 23 02:58 nm
-rwxr-xr-x 2 test 2353136 Dec 23 02:58 objcopy
-rwxr-xr-x 2 test 3870336 Dec 23 02:58 objdump
-rwxr-xr-x 2 test 2226872 Dec 23 02:58 ranlib
-rwxr-xr-x 2 test 1284528 Dec 23 02:58 readelf
-rwxr-xr-x 2 test 2353136 Dec 23 02:58 strip
  • ar: Create, Modify, and Extract from archives

  • as: The portable GNU assembler

  • ld: The GNU linker

  • ld.bfd: The linker accesses object and archive files using the BFD (Binary File Descriptor) libraries.

  • nm: List symbols from object files

  • objcopy: Copy and translate object files

  • objdump: Display information from object files

  • ranlib: Generate an index to an archive

  • readelf: Display information about ELF (Executable and Linkable Format) files

  • strip: Discard symbols and other data from object files

  • Make sure the current directory is “openwrt”

$ pwd

$HOME/openwrt/bin/targets/bcm27xx/bcm2711


$ ls -l

-rw-r--r-- 1 test     1652 Jan 16 14:18 config.buildinfo
-rw-r--r-- 1 test       83 Jan 16 14:18 feeds.buildinfo
-rw-r--r-- 1 test 17117078 Jan 16 14:20 openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz
-rw-r--r-- 1 test 17117925 Jan 16 14:20 openwrt-bcm27xx-bcm2711-rpi-4-ext4-sysupgrade.img.gz
-rw-r--r-- 1 test     4207 Jan 16 14:20 openwrt-bcm27xx-bcm2711-rpi-4.manifest
-rw-r--r-- 1 test 15350996 Jan 16 14:20 openwrt-bcm27xx-bcm2711-rpi-4-squashfs-factory.img.gz
-rw-r--r-- 1 test 15351843 Jan 16 14:20 openwrt-bcm27xx-bcm2711-rpi-4-squashfs-sysupgrade.img.gz
drwxr-xr-x 2 test     4096 Jan 16 14:20 packages
-rw-r--r-- 1 test     2141 Jan 16 14:20 profiles.json
-rw-r--r-- 1 test      912 Jan 16 14:20 sha256sums
-rw-r--r-- 1 test       18 Jan 16 14:20 version.buildinfo
  • config.buildinfo: Creating a config from .config backup or config.buildinfo

  • feeds.buildinfo: Collection of packages.

  • openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz: In this openwrt image is built

  • openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz: In this openwrt image is built

  • ext4: This firmware contains a regular ext4 Linux partition

  • factory: Use when flashing

  • img: image file

  • gz: extension for gzip

  • sysupgrade: sysupgrade is designed to be flashed from OpenWrt/LEDE itself

  • manifest:

  • squashfs: This firmware contains a type of partition that is compressed and mounts read-only

  • profiles.json: A profile is a set of documents with a profile relationship to the profile.

  • json: JavaScript Object Notation

  • sha256sums: An SHA-256 checksum is a sequence of numbers and letters that you can use to check that your copy of a downloaded update file is identical to the original

  • version.buildinfo: It will be version of the openwrt

$ du -h openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz

17M     openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz
  • To extract image file following are the commands

$ pwd

$HOME/openwrt/bin/targets/bcm27xx/bcm2711
  • After extracting you will get openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img

$ gunzip openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz

$ ls -l

-rw-r--r-- 1 test      1652 Jan 16 19:57 config.buildinfo
-rw-r--r-- 1 test        71 Jan 16 19:57 feeds.buildinfo
-rw-r--r-- 1 test 184549376 Jan 16 20:02 openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img
-rw-r--r-- 1 test  17117911 Jan 16 19:58 openwrt-bcm27xx-bcm2711-rpi-4-ext4-sysupgrade.img.gz
-rw-r--r-- 1 test      4207 Jan 16 19:58 openwrt-bcm27xx-bcm2711-rpi-4.manifest
-rw-r--r-- 1 test  15351033 Jan 16 19:58 openwrt-bcm27xx-bcm2711-rpi-4-squashfs-factory.img.gz
-rw-r--r-- 1 test  15351880 Jan 16 19:58 openwrt-bcm27xx-bcm2711-rpi-4-squashfs-sysupgrade.img.gz
drwxr-xr-x 2 test      4096 Jan 16 19:58 packages
-rw-r--r-- 1 test      2141 Jan 16 19:59 profiles.json
-rw-r--r-- 1 test       912 Jan 16 19:59 sha256sums
-rw-r--r-- 1 test        18 Jan 16 19:57 version.buildinfo
$ file openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img

openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img: DOS/MBR boot sector; partition 1 : ID=0xc, active, start-CHS (0x20,2,3), end-CHS (0x228,2,34), startsector 8192, 131072 sectors; partition 2 : ID=0x83, start-CHS (0x249,0,37), end-CHS (0x196,1,25), startsector 147456, 212992 sectors

* There are 2 partitions are there in .img file
  • kpartx: Create device maps from partition tables

$ sudo apt-get install kpartx
  • -a: Add partition mappings

  • -v: Operate verbosely

$ sudo kpartx -av openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img

add map loop29p1 (253:0): 0 131072 linear 7:29 8192
add map loop29p2 (253:10): 0 212992 linear 7:29 147456
$ sudo mkdir -p /mnt/boot

$ sudo mount /dev/mapper/loop29p1 /mnt/boot

$ sudo mkdir -p /mnt/root

$ sudo mount /dev/mapper/loop29p2 /mnt/root
$ ls -l /mnt/boot

-rwxr-xr-x 1 root root    54477 Dec 21 15:56 bcm2711-rpi-400.dtb
-rwxr-xr-x 1 root root    54388 Dec 21 15:56 bcm2711-rpi-4-b.dtb
-rwxr-xr-x 1 root root    54997 Dec 21 15:56 bcm2711-rpi-cm4.dtb
-rwxr-xr-x 1 root root       90 Dec 21 15:56 cmdline.txt
-rwxr-xr-x 1 root root      581 Dec 21 15:56 config.txt
-rwxr-xr-x 1 root root      496 Dec 21 15:56 COPYING.linux
-rwxr-xr-x 1 root root      638 Dec 21 15:56 distroconfig.txt
-rwxr-xr-x 1 root root     3171 Dec 21 15:56 fixup4cd.dat
-rwxr-xr-x 1 root root     5394 Dec 21 15:56 fixup4.dat
-rwxr-xr-x 1 root root     8378 Dec 21 15:56 fixup4x.dat
-rwxr-xr-x 1 root root 12068872 Dec 21 15:56 kernel8.img
-rwxr-xr-x 1 root root     1594 Dec 21 15:56 LICENCE.broadcom
drwxr-xr-x 2 root root    24576 Dec 21 15:56 overlays
-rwxr-xr-x 1 root root   803644 Dec 21 15:56 start4cd.elf
-rwxr-xr-x 1 root root  2248864 Dec 21 15:56 start4.elf
-rwxr-xr-x 1 root root  2996328 Dec 21 15:56 start4x.elf

$ ls -l /mnt/root

drwxr-xr-x  2 root root 4096 Dec 21 15:56 bin
drwxr-xr-x  2 root root 4096 Dec 21 15:56 dev
drwxr-xr-x 23 root root 4096 Dec 21 15:56 etc
drwxr-xr-x 11 root root 4096 Dec 21 15:56 lib
lrwxrwxrwx  1 root root    3 Dec 21 15:56 lib64 -> lib
drwx------  2 root root 4096 Jan  1  1970 lost+found
drwxr-xr-x  2 root root 4096 Dec 21 15:56 mnt
drwxr-xr-x  2 root root 4096 Dec 21 15:56 overlay
drwxr-xr-x  2 root root 4096 Dec 21 15:56 proc
drwxrwxr-x  2 root root 4096 Dec 21 15:56 rom
drwxr-x---  2 root root 4096 Dec 21 15:56 root
drwxr-xr-x  2 root root 4096 Dec 21 15:56 sbin
drwxr-xr-x  2 root root 4096 Dec 21 15:56 sys
drwxrwxrwt  2 root root 4096 Dec 21 15:56 tmp
drwxr-xr-x  7 root root 4096 Dec 21 15:56 usr
lrwxrwxrwx  1 root root    3 Dec 21 15:56 var -> tmp
drwxr-xr-x  2 root root 4096 Dec 21 15:56 www
$ umount /mnt/boot

$ umount /mnt/root
  • using meminfo command we can check the space acquired on the RAM.

root@OpenWrt:/# cat /proc/meminfo
  • using df command we can interpret the space acquire on the flash.

root@OpenWrt:/# df -h

Filesystem                Size      Used Available Use% Mounted on
/dev/root               102.3M     30.1M     70.1M  30% /
tmpfs                   458.3M    140.0K    458.2M   0% /tmp
/dev/mmcblk0p1           63.9M     20.1M     43.7M  32% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
  • this needs to be correlated with the mount command output since this df also lists out virtual filesystem.

root@OpenWrt:/# mount
  • from verifying this two outputs we can come to the following conclusion.

    • /dev/mmcblk0p1 is mounted to /boot.

    • /dev/root is mounted on /

    • this two filesystem comprises of the space acquired on flash.

root@OpenWrt:/# cat /etc/os-release | grep BUILD_ID

BUILD_ID="r24685-4a2ff73177"
  • Check the linux kernel version using the following command

root@OpenWrt:/# uname -a

Linux OpenWrt 6.1.69 #0 SMP Thu Dec 21 10:26:35 2023 aarch64 GNU/Linux
  • Check the openwrt version using the following command

root@OpenWrt:/# cat /etc/openwrt_release

DISTRIB_ID="OpenWrt"
DISTRIB_RELEASE="SNAPSHOT"
DISTRIB_REVISION="r24685-4a2ff73177"
DISTRIB_TARGET="bcm27xx/bcm2711"
DISTRIB_ARCH="aarch64_cortex-a72"
DISTRIB_DESCRIPTION="OpenWrt SNAPSHOT r24685-4a2ff73177"
DISTRIB_TAINTS="no-all override"
root@OpenWrt:/# lsmod
root@OpenWrt:/# find / -iname "*.ko"
root@OpenWrt:/# find / -iname "*.so"
root@OpenWrt:/# find / -iname "*.a"
root@OpenWrt:/# find /usr/bin
root@OpenWrt:/# find /usr/sbin
root@OpenWrt:/# cd bin
root@OpenWrt:/# cd sbin
  • ps: Displays information about a selection of the active processes

root@OpenWrt:/# ps
  • TODO


  • TODO


  • TODO


root@OpenWrt:/# top
  • TODO


root@OpenWrt:/# mount
root@OpenWrt:/# fdisk -l
  • In this section, we will know RAM usage

root@OpenWrt:/# free

total        used         free      shared        buff/cache   available
Mem:        3892552       43880     3830560         140       18112     3803272
Swap:             0           0           0
root@OpenWrt:/# ifconfig -a

br-lan    Link encap:Ethernet  HWaddr E4:5F:01:3C:F4:21
inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
inet6 addr: fddb:1aa5:ff14::1/60 Scope:Global
UP BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr E4:5F:01:3C:F4:21
UP BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:65536  Metric:1
RX packets:320 errors:0 dropped:0 overruns:0 frame:0
TX packets:320 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:24960 (24.3 KiB)  TX bytes:24960 (24.3 KiB)

wlan0     Link encap:Ethernet  HWaddr E4:5F:01:3C:F4:22
BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
root@OpenWrt:/# iw dev

phy#0
      Interface wlan0
            ifindex 3
            wdev 0x1
            addr e4:5f:01:3c:f4:22
            type managed
            channel 34 (5170 MHz), width: 20 MHz, center1: 5170 MHz
root@OpenWrt:/# iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     no wireless extensions.

br-lan    no wireless extensions.

What is /.bashrc file?