Build procedure to generate R-Pi image with Firmware upgrade

The build procedure for broadband are as follows:

  1. repo init -u https://code.rdkcentral.com/r/manifests -b rdk-next -m rdkb-extsrc.xml
  2. repo sync -j4 --no-clone-bundle
  3. source meta-cmf-raspberrypi/setup-environment (Select option raspberrypi-rdk-broadband.conf)
  4. bitbake rdk-generic-broadband-image 

The build procedure for video is as follows:

  1. repo init -u https://code.rdkcentral.com/r/manifests -b rdk-next -m rdkv-extsrc.xml
  2. repo sync -j4 --no-clone-bundle
  3. source meta-cmf-raspberrypi/setup-environment (Select option raspberrypi-rdk-hybrid-westeros.conf)
  4. bitbake rdk-generic-hybrid-westeros-wpe-image

Flashing the image


It is must to have minimal size of 8GB SD-Card for Firmware upgrade support


Command to flash the image

Generated image has to be flashed to an SD card using this command in local PC:

$ sudo dd if=<path to ImageName.rpi-sdimg> of=<path to SD card space> bs=4M

Ex:

$ sudo dd if=rdk-generic-broadband-image-raspberrypi-rdk-broadband.rpi-sdimg of=/dev/sdb bs=4M

The SD card is inserted to the Raspberry Pi board and booted to check for containers created.

The Raspberry Pi board is connected to the PC via a USB to serial converter and the logs can be checked in console or can be connected via HDMI cable to a TV and logs will be shown in the terminal

Creating checksum file

It is necessary to flash the stable image during upgrade. So checksum file has to be created for the image to be uploaded using below command

md5sum "<imagefile_name>.rootfs.rpi-sdimg" > imagefile_name.txt

After checksum file is created, place this file in tftp location along with actual image file which is expected by firmware upgrade script. Without which firmware upgrade wont be allowed by scripts

Creating Multi-Boot compatible SD-CARD if RDKB is Flashed for first time

If RDKV is flashed for the first time, please ignore below procedure in current section


If firmware upgrade is intended for multi-boot, it is necessary to have partizion size matching to both RDKV and RDKB image size ( especially rootfs ). 

But size of RDKB image is around 300 MB approx, but RDKV is more than 1 GB. So it is necessary to have RDKB image flashed SD card should have partition compatible to RDKB.

To make compatible, size of RDKB rootfs partition should be increased to 2 GB ( 2098 MB) from 300MB default

This resize can be achieved using gpartedui tool which should be available in host pc


sudo apt-get install gparted

https://gparted.org/display-doc.php%3Fname%3Dmoving-space-between-partitions


Please resize the rootfs partition to 2098 MB or 2GB (/dev/sdb1) accordingly from below procedure as captured in various stages

  1. Select gparted tool from menu


2. Select the rootfs partition of format ext3 for resize/move option



3. Resize the rootfs partition by giving new size image to 2098 MiB


4. After resize , position stands as below



5.After modifying size, "Apply all operations" using tick symbol in UI which displays icon as below




6. After giving "Apply icon" position stands as below



7. After resizing is completed 

8. After applying close size increased to 2 GB can be seen


Test Setup Block Diagram for RPI RDKB/V Firmware upgrade



Setting up XCONF Server  


http://34.219.243.214:9093/admin

Please follow the below procedure in xconf server for placing new firmware for upgrade to specific device and model ( RPI in this case ) as a reference:

               → RPI will support only tftp protocol . No http protocol support is provided yet

Workflow

XConf Server :

1) Create Environment

2) Create Model

3) Create MAC list by entering the MAC address of Rpi board

4) Create the Firmware Configuration by providing Firmware Description, File name as Image name to be downloaded from Xconf server, and version is the same image name without the extension (.rootfs.rpi-sdimg) and select Model(ex. RPI_BB) form the listed Models

5) Create MAC rule by providing rule name, Build condition is eStbMac, choose the option IN_LIST and for next field, select the MAC list created for RPi board, verify that based on the MAC list selection, Firmware Config will be automatically displayed under Action section.


6) Go to Download Location Round Robin Filter page and click on Edit. Provide Location and full http location as mentioned in the snapshot below. Select the option "Never use HTTP". Select the Rogue model from the models displayed in the section (ex. RPI, RPI_BB). Verify that Firmware versions are displayed based on the selected Rogue models.

Provide TFTP Server IP address in the IPv4 locations and provide 100 in the percentage field. If there are multiple TFTP servers then add them under IPv4 locations and distribute the percentage among them like total should be 100% and save this page.


7. Verify that XConf Server configuration displays the Json response from the mentioned URL:

http://<Xconf Server IP:port no.>/xconf/swu/stb?eStbMac=<MAC address of Rpi board>

For ex. http://34.219.243.214:9092/xconf/swu/stb?eStbMac=B8:27:EB:F6:70:8C


TFTP Server:

Configure tftp server and keep the image file and reapective md5 checksum file inside tftp folder. Example given below:

1.Verify the content of tftp file (use  vi /etc/xinetd.d/tftp command)

service tftp

{

protocol = udp

port = 69

socket_type = dgram

wait = yes

user = nobody

server = /usr/sbin/in.tftpd

server_args = -c -v -s /home/amrita/tftphome

disable = no

}

2. Verify the content of tftpd-hpa:

# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/home/amrita/tftphome/"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-s -c -1"

3. Verify the tftp folder location:

amrita@amrita-OptiPlex-9020:~/tftphome$ pwd

/home/amrita/tftphome

4. Verify that image file and its respective md5 checksum file is present in the tftp folder:

amrita@amrita-OptiPlex-9020:~/tftphome$ ls

rdkb-generic-broadband-image_default_20190812074412.rootfs.rpi-sdimg

rdkb-generic-broadband-image_default_20190812074412.txt

5. Start tftp server and xinetd:

sudo service tftpd-hpa restart

/etc/init.d/xinetd restart

RPi - Board :

  1. Flash the RDKB image supported for Firmware upgrade feature in the Rpi and verify the 2 partitions(ex. mmcblk0p1, mmcblk0p2) present under dev folder (use command ls /dev)
  2. Device auto-reboots and verify there are 2 more additional partitions are created (ex. mmcblk0p3, mmcblk0p4).
  3. Open /etc/include.properties file and verify the CLOUDURL parameter where XConf Server URL is configured
  4. Verify the image version ( cat /version.txt) displays the flashed image version
  5. Open /rdklogs/logs/swupdate.log to verify the communication from RPI board with XConf Server and the download status
  6. Verify the tftp download is happening by noticing the change of file size using below command:cd /extblock/tftpimage/imagedwnldls -lh  (use this command frequently to verify the file size change)
  7. Once image download completed, the Rpi board will auto reboot and come up with downloaded image
  8.  Verify the version of booted image which shows the downloaded image version

Conclusion

Please find the summary on firmware upgrade explained above


Note : 1. RPI will go for reboot while booting for the first time, since two more partition needs to be created which requires reboot. Depends on the image present in xconf and RPI, further reboot will happen for upgrade. Please refer to design (RDKB RPI Firmware Upgrade - Design - 2019 M7) for how firmware upgrade works with bank switching

2. SD card should be zero filled formatted before starting the firmware upgrade procedure. DriveWipe software is used for this. Please refer the you-tube video link for the SD card full format process.

https://youtu.be/CZhsVBEMYuk

3. If the user wants to view swupdate.log file then follow below steps:
    a) Disable log rotation feature - This wipes out the log file if size exceeds after 1min
        For B image  command - systemctl disable rdkbLogMonitor
        For V image command - systemctl disable logrotation.service
   b) Reboot the box - This will make swupdate.service restart and user can start getting swupdate.log both for B and V image

4. Download of Video image(size 592 MB) takes roughly 40 min time and Broadband(size 292MB) image takes roughly 20 min time from Cloud server(Xconf). Broadband to Video or Video to Broadband is taking approx 15 min time to boot up after download from XConf server is completed.

5. Minimum extended partition should be 1GB, to verify multiboot feature.