# SONiC build master branch ###### tags: `unicamp` This document describes how to build SONiC master branch. First 5 steps builds SONiC for PLATFORM=vs. Step 6 targets other platforms. ## 1. Clone SONiC repository and select target commit ```bash= git clone https://github.com/Azure/sonic-buildimage.git cd sonic-buildimage git checkout 78e867a79403efd80915e66ff51ebe1733d72a2a ``` ## 2. Load kernel module for filesystem overlay ```bash= sudo modprobe overlay ``` ## 3. Make sure docker is running ```bash= systemctl start docker systemctl status docker ``` ## 4. Configure and start build process ```bash= make init make configure PLATFORM=vs time make SONIC_BUILD_JOBS=4 target/sonic-vs.img.gz ``` :::warning Last line is the magic step. Documentation page only shows ```make SONIC_BUILD_JOBS=4 all```. This results in the error: ```make: *** No rule to make target 'target/docker-sonic-vs.gz', needed by 'all'. Stop.``` ***DO NOT USE TARGET all.*** ::: ## 5. After the build process finishes, you will end up with the following files (```ls target/```): :::spoiler Click here to see the file list cache debs docker-base-bullseye.gz docker-base-bullseye.gz-load.log docker-base-bullseye.gz.log docker-base-buster.gz docker-base-buster.gz-load.log docker-base-buster.gz.log docker-config-engine-bullseye.gz docker-config-engine-bullseye.gz-load.log docker-config-engine-bullseye.gz.log docker-config-engine-buster.gz docker-config-engine-buster.gz-load.log docker-config-engine-buster.gz.log docker-database.gz docker-database.gz.log docker-dhcp-relay.gz docker-dhcp-relay.gz.log docker-fpm-frr.gz docker-fpm-frr.gz.log docker-gbsyncd-vs.gz docker-gbsyncd-vs.gz.log docker-lldp.gz docker-lldp.gz.log docker-macsec.gz docker-macsec.gz.log docker-mux.gz docker-mux.gz.log docker-nat.gz docker-nat.gz.log docker-orchagent.gz docker-orchagent.gz.log docker-platform-monitor.gz docker-platform-monitor.gz.log docker-router-advertiser.gz docker-router-advertiser.gz.log docker-sflow.gz docker-sflow.gz.log docker-snmp.gz docker-snmp.gz.log docker-sonic-mgmt-framework.gz docker-sonic-mgmt-framework.gz.log docker-sonic-telemetry.gz docker-sonic-telemetry.gz.log docker-swss-layer-buster.gz docker-swss-layer-buster.gz-load.log docker-swss-layer-buster.gz.log docker-syncd-vs.gz docker-syncd-vs.gz.log docker-teamd.gz docker-teamd.gz.log files python-debs python-wheels sonic-vs.bin sonic-vs.img.gz sonic-vs.img.gz.log versions ::: ## 6. Building for other targets In order to build for other targets, follow all the previous steps (1, 2, and 3). Change the lines 2 and 3 of step 4 according to the target platform: ##### PLATFORM=barefoot ```bash= make configure PLATFORM=barefoot time make SONIC_BUILD_JOBS=4 target/sonic-barefoot.bin ``` ##### PLATFORM=broadcom ```bash= make configure PLATFORM=broadcom time make SONIC_BUILD_JOBS=4 target/sonic-broadcom.bin ``` ##### PLATFORM=centec ```bash= make configure PLATFORM=centec time make SONIC_BUILD_JOBS=4 target/sonic-centec.bin ``` ##### PLATFORM=mellanox ```bash= make configure PLATFORM=mellanox time make SONIC_BUILD_JOBS=4 target/sonic-mellanox.bin ``` ## Appendix A - Builds tested so far ## BUILD SYSTEMS ###### BUILD SYSTEM 1 - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (4/12 cores) - 32 GB RAM - Disk: nvme - OS: 20.04.4 LTS (Focal Fossa) ###### BUILD SYSTEM 2 - Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz (4/12) - 57 GB RAM - Disk: mechanical - OS: 20.04.4 LTS (Focal Fossa) ## PLATFORMS ### vs - Using BUILD SYSTEM 2 ## broadcom - Using BUILD SYSTEM 1 real 115m50,612s user 0m2,471s sys 0m1,205s ## centec - Using BUILD SYSTEM 1 real 89m51,259s user 0m2,402s sys 0m1,043s