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 test 2226840 Feb 12 16:55 ar
-rwxr-xr-x 2 test test 3467944 Feb 12 16:55 as
-rwxr-xr-x 4 test test 4025800 Feb 12 16:55 ld
-rwxr-xr-x 4 test test 4025800 Feb 12 16:55 ld.bfd
-rwxr-xr-x 2 test test 2217128 Feb 12 16:55 nm
-rwxr-xr-x 2 test test 2353136 Feb 12 16:55 objcopy
-rwxr-xr-x 2 test test 3870368 Feb 12 16:55 objdump
-rwxr-xr-x 2 test test 2226872 Feb 12 16:55 ranlib
-rwxr-xr-x 2 test test 1284560 Feb 12 16:55 readelf
-rwxr-xr-x 2 test test 2353136 Feb 12 16:55 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/bcm2710


$ ls -l

-rw-r--r-- 1 test test     1989 Feb 12 17:40 config.buildinfo
-rw-r--r-- 1 test test      395 Feb 12 17:41 feeds.buildinfo
-rw-r--r-- 1 test test 19398066 Feb 12 18:13 openwrt-bcm27xx-bcm2710-rpi-3-ext4-factory.img.gz
-rw-r--r-- 1 test test 19399049 Feb 12 18:13 openwrt-bcm27xx-bcm2710-rpi-3-ext4-sysupgrade.img.gz
-rw-r--r-- 1 test test     4263 Feb 12 18:13 openwrt-bcm27xx-bcm2710-rpi-3.manifest
-rw-r--r-- 1 test test 17360143 Feb 12 18:12 openwrt-bcm27xx-bcm2710-rpi-3-squashfs-factory.img.gz
-rw-r--r-- 1 test test 17361126 Feb 12 18:13 openwrt-bcm27xx-bcm2710-rpi-3-squashfs-sysupgrade.img.gz
drwxr-xr-x 2 test test     4096 Feb 12 18:13 packages
-rw-r--r-- 1 test test     2378 Feb 12 18:13 profiles.json
-rw-r--r-- 1 test test      912 Feb 12 18:13 sha256sums
-rw-r--r-- 1 test test       18 Feb 12 17:41 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-bcm2710-rpi-3-ext4-factory.img.gz

19M     openwrt-bcm27xx-bcm2710-rpi-3-ext4-factory.img.gz
  • To extract image file following are the commands

$ pwd

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

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

$ ls -l

-rw-r--r-- 1 test test      1989 Feb 12 17:40 config.buildinfo
-rw-r--r-- 1 test test       395 Feb 12 17:41 feeds.buildinfo
-rw-r--r-- 1 test test 184549376 Feb 12 18:13 openwrt-bcm27xx-bcm2710-rpi-3-ext4-factory.img
-rw-r--r-- 1 test test  19399049 Feb 12 18:13 openwrt-bcm27xx-bcm2710-rpi-3-ext4-sysupgrade.img.gz
-rw-r--r-- 1 test test      4263 Feb 12 18:13 openwrt-bcm27xx-bcm2710-rpi-3.manifest
-rw-r--r-- 1 test test  17360143 Feb 12 18:12 openwrt-bcm27xx-bcm2710-rpi-3-squashfs-factory.img.gz
-rw-r--r-- 1 test test  17361126 Feb 12 18:13 openwrt-bcm27xx-bcm2710-rpi-3-squashfs-sysupgrade.img.gz
drwxr-xr-x 2 test test      4096 Feb 12 18:13 packages
-rw-r--r-- 1 test test      2378 Feb 12 18:13 profiles.json
-rw-r--r-- 1 test test       912 Feb 12 18:13 sha256sums
-rw-r--r-- 1 test test        18 Feb 12 17:41 version.buildinfo
$ file openwrt-bcm27xx-bcm2711-rpi-3-ext4-factory.img

openwrt-bcm27xx-bcm2710-rpi-3-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-3-ext4-factory.img

add map loop28p1 (252:0): 0 131072 linear 7:28 8192
add map loop28p2 (252:1): 0 212992 linear 7:28 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    31359 Feb 12 14:27 bcm2710-rpi-2-b.dtb
-rwxr-xr-x 1 root root    33555 Feb 12 14:27 bcm2710-rpi-3-b.dtb
-rwxr-xr-x 1 root root    34182 Feb 12 14:27 bcm2710-rpi-3-b-plus.dtb
-rwxr-xr-x 1 root root    31254 Feb 12 14:27 bcm2710-rpi-cm3.dtb
-rwxr-xr-x 1 root root    32524 Feb 12 14:27 bcm2710-rpi-zero-2.dtb
-rwxr-xr-x 1 root root    52476 Feb 12 14:27 bootcode.bin
-rwxr-xr-x 1 root root       90 Feb 12 14:27 cmdline.txt
-rwxr-xr-x 1 root root      572 Feb 12 14:27 config.txt
-rwxr-xr-x 1 root root      496 Feb 12 14:27 COPYING.linux
-rwxr-xr-x 1 root root      678 Feb 12 14:27 distroconfig.txt
-rwxr-xr-x 1 root root     3180 Feb 12 14:27 fixup_cd.dat
-rwxr-xr-x 1 root root     7269 Feb 12 14:27 fixup.dat
-rwxr-xr-x 1 root root    10244 Feb 12 14:27 fixup_x.dat
-rwxr-xr-x 1 root root 12046344 Feb 12 14:27 kernel8.img
-rwxr-xr-x 1 root root     1594 Feb 12 14:27 LICENCE.broadcom
drwxr-xr-x 2 root root    26624 Feb 12 14:27 overlays
-rwxr-xr-x 1 root root   808060 Feb 12 14:27 start_cd.elf
-rwxr-xr-x 1 root root  2979264 Feb 12 14:27 start.elf
-rwxr-xr-x 1 root root  3726216 Feb 12 14:27 start_x.elf


$ ls -l /mnt/root

drwxr-xr-x  2 root root 4096 Feb 12 14:27 bin
drwxr-xr-x  2 root root 4096 Feb 12 14:27 dev
drwxr-xr-x 23 root root 4096 Feb 12 14:27 etc
drwxr-xr-x 11 root root 4096 Feb 12 14:27 lib
lrwxrwxrwx  1 root root    3 Feb 12 14:27 lib64 -> lib
drwx------  2 root root 4096 Jan  1  1970 lost+found
drwxr-xr-x  2 root root 4096 Feb 12 14:27 mnt
drwxr-xr-x  2 root root 4096 Feb 12 14:27 overlay
drwxr-xr-x  2 root root 4096 Feb 12 14:27 proc
drwxrwxr-x  2 root root 4096 Feb 12 14:27 rom
drwxr-x---  2 root root 4096 Feb 12 14:27 root
drwxr-xr-x  2 root root 4096 Feb 12 14:27 sbin
drwxr-xr-x  3 root root 4096 Feb 12 14:27 srv
drwxr-xr-x  2 root root 4096 Feb 12 14:27 sys
drwxrwxrwt  2 root root 4096 Feb 12 14:27 tmp
drwxr-xr-x  7 root root 4096 Feb 12 14:27 usr
lrwxrwxrwx  1 root root    3 Feb 12 14:27 var -> tmp
drwxr-xr-x  2 root root 4096 Feb 12 14:27 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="r16495-bf0c965af0"
  • Check the linux kernel version using the following command

root@OpenWrt:/# uname -a

Linux OpenWrt 5.4.179 #0 SMP Wed Feb 16 20:29:10 2022 aarch64 GNU/Linux
  • Check the openwrt version using the following command

root@OpenWrt:/# cat /etc/openwrt_release

DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='21.02.2'
DISTRIB_REVISION='r16495-bf0c965af0'
DISTRIB_TARGET='bcm27xx/bcm2710'
DISTRIB_ARCH='aarch64_cortex-a53'
DISTRIB_DESCRIPTION='OpenWrt 21.02.2 r16495-bf0c965af0'
DISTRIB_TAINTS=''
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:         489820       12392      461324       14324       16104      437640
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?