Some questions about building from source

https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem
I am moving on to start building the firmwares to my devices from source code.

But I have two questions at this point:

  1. make -j $(nproc) defconfig download clean world
    In the instruction the make command have option world?
    But world is only mentioned in the instruction with the combination download for setting the CPU cores used? What is the actual purpose of this world option?

  2. How do you prefer handling the building process from source if you have four different devices that are supposed to have different packages installed and one device also have changed configs?
    Do you setup one buildroot folder for every device (probably easiest solution but takes a lot of SSD space) or is it possible to have all the packages (feeds) used for all devices downloaded to one buildroot folder and only have different makemenu config file that are changed for the device the build are made for?

1 Like

I have never used world (except for Gentoo :stuck_out_tongue:). A regular make will do all those things listed except for clean, if world is not documented then I wonder what its use is.

As for building for multiple devices, use environments:
$ ./scripts/env

It allows you to use per image/architecture profiles. Configure once, save as a new profile, create a new one, configure, save, etc. Then you can easily switch between them. My own build script e.g. loops over six architectures ('targets'), each with multiple devices, and relies on the env script for that.

Another neat thing you can use is CONFIG_TARGET_PER_DEVICE_ROOTFS, which allows you to specify additional packages for specific devices. E.g. for model A, you'd like Unbound to be included, for model B, qos-scripts, etc. Within the same target, that is.

There's no need to set up a separate buildroot for different targets, what I do recommend though is that you do not mix release branches. E.g. one folder for master builds, another for 21.02 builds. You can technically do it all in one folder but that might get messy.

2 Likes

Thanks that sound really promising. I try that in the near future.
To begin with I will hang around in the stable 21.02 branch at least to learn how the build process works.
Then work out the github working process.
But my the long term goal for now is to at least make a working device setup for my new DGS-1210-10MP as a spinoff from the DGS-1210-10P, but more on that in the future…

Why doesn’t make use the only config file I have saved in buildroot?
It doesn’t matter if i open menuconfig, load my wrt3200acm.config file and exit or save it again.

The make output is always a random Ath79 device which is the default menuconfig pre setting?

Where do I set what config file the make command are supposed to use even though it only have one file to choose from, which it doesn’t use?

There's only one config file and thats .config. Copy yours over, rename it to .config, link it - whatever you want, but it's the only configuration file the buildroot bothers with.

Tried doing a completely new config for ER4 instead of wrt3200acm, and if I open the config as a txt it is saying “build a ER4” so the config file is correct.
But the only thing make is producing every time no matter the config file is probably a perfect working Ath79 caramola2 image, if I had that device.

Tried without any config file and then the compiler failed.

Is this some kind of wierd feature because I use a VMbox Ubuntu?

Paste the commands you enter (no screenshot, text please).

Started from scratch with a new build root.
https://forum.openwrt.org/t/cant-install-libpam-when-compiling-openwrt/99702/2?u=flygarn12

git clone https://git.openwrt.org/openwrt/openwrt.git
cd ~/openwrt
git pull
git checkout openwrt-21.02
./scripts/feeds update -a	
./scripts/feeds install -a	#this gives warning for missing libpam, liblzma, libnetsnmp
./scripts/feeds update -a -f
./scripts/feeds install -a -f
make menuconfig # only set device to ER4 and save as er4.config
make	# Result in menuconfig automatically opening again but with Ath9 device (se log below)?
make defconfig	# configuration written to .config
make

The log when trying to run make command after menuconfig.

nnnnn@nnnnn-VirtualBox:~/openwrt$ make menuconfig


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

nnnnn@nnnnn-VirtualBox:~/openwrt$ make
make[2]: Entering directory '/home/nnnnn/openwrt/scripts/config'
cc -O2   -c -o conf.o conf.c
cc   conf.o confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o symbol.o util.o   -o conf
make[2]: Leaving directory '/home/nnnnn/openwrt/scripts/config'
make[2]: Entering directory '/home/nnnnn/openwrt'
make[3]: Entering directory '/home/nnnnn/openwrt/scripts/config'
set -e; mkdir -p ./; trap "rm -f ./.mconf-cfg.tmp" EXIT; { /bin/sh mconf-cfg.sh; } > ./.mconf-cfg.tmp; if [ ! -r mconf-cfg ] || ! cmp -s mconf-cfg ./.mconf-cfg.tmp; then true '  UPD     mconf-cfg'; mv -f ./.mconf-cfg.tmp mconf-cfg; fi
make[3]: Leaving directory '/home/nnnnn/openwrt/scripts/config'
make[3]: Entering directory '/home/nnnnn/openwrt'
make[3]: Leaving directory '/home/nnnnn/openwrt'


Your configuration changes were NOT saved.

make[2]: Leaving directory '/home/nnnnn/openwrt'
make[2]: *** No rule to make target '.config', needed by '/home/nnnnn/openwrt/staging_dir/target-_/stamp/.target_prereq'.  Stop.
make[1]: *** [/home/nnnnn/openwrt/include/toplevel.mk:208: prereq] Error 2
make: *** [/home/nnnnn/openwrt/include/toplevel.mk:228: world] Error 2
nnnnn@nnnnn-VirtualBox:~/openwrt$ make defconfig
#
# configuration written to .config
#
nnnnn@nnnnn-VirtualBox:~/openwrt$ make
time: target/linux/prereq#0.63#0.05#0.68
 make[1] world

And the top part of my er4.config file:

#
# Automatically generated file; DO NOT EDIT.
# OpenWrt Configuration
#
CONFIG_MODULES=y
CONFIG_HAVE_DOT_CONFIG=y
# CONFIG_TARGET_sunxi is not set
# CONFIG_TARGET_apm821xx is not set
# CONFIG_TARGET_ath25 is not set
# CONFIG_TARGET_ath79 is not set
# CONFIG_TARGET_bcm27xx is not set
# CONFIG_TARGET_bcm53xx is not set
# CONFIG_TARGET_bcm47xx is not set
# CONFIG_TARGET_bcm4908 is not set
# CONFIG_TARGET_bcm63xx is not set
CONFIG_TARGET_octeon=y
# CONFIG_TARGET_gemini is not set
# CONFIG_TARGET_mpc85xx is not set
# CONFIG_TARGET_imx6 is not set
# CONFIG_TARGET_mxs is not set
# CONFIG_TARGET_lantiq is not set
# CONFIG_TARGET_malta is not set
# CONFIG_TARGET_pistachio is not set
# CONFIG_TARGET_mvebu is not set
# CONFIG_TARGET_kirkwood is not set
# CONFIG_TARGET_mediatek is not set
# CONFIG_TARGET_ramips is not set
# CONFIG_TARGET_at91 is not set
# CONFIG_TARGET_tegra is not set
# CONFIG_TARGET_layerscape is not set
# CONFIG_TARGET_octeontx is not set
# CONFIG_TARGET_oxnas is not set
# CONFIG_TARGET_armvirt is not set
# CONFIG_TARGET_ipq40xx is not set
# CONFIG_TARGET_ipq806x is not set
# CONFIG_TARGET_realtek is not set
# CONFIG_TARGET_rockchip is not set
# CONFIG_TARGET_arc770 is not set
# CONFIG_TARGET_archs38 is not set
# CONFIG_TARGET_omap is not set
# CONFIG_TARGET_uml is not set
# CONFIG_TARGET_zynq is not set
# CONFIG_TARGET_x86 is not set
# CONFIG_TARGET_MULTI_PROFILE is not set
# CONFIG_TARGET_octeon_Default is not set
# CONFIG_TARGET_octeon_DEVICE_generic is not set
# CONFIG_TARGET_octeon_DEVICE_itus_shield-router is not set
# CONFIG_TARGET_octeon_DEVICE_ubnt_edgerouter is not set
CONFIG_TARGET_octeon_DEVICE_ubnt_edgerouter-4=y
# CONFIG_TARGET_octeon_DEVICE_ubnt_edgerouter-lite is not set
CONFIG_HAS_DEVICES=y
CONFIG_TARGET_BOARD="octeon"
CONFIG_TARGET_SUBTARGET="generic"
CONFIG_TARGET_PROFILE="DEVICE_ubnt_edgerouter-4"
CONFIG_TARGET_ARCH_PACKAGES="mips64_octeonplus"
CONFIG_DEFAULT_TARGET_OPTIMIZATION="-Os -pipe -mno-branch-likely -march=octeon+ -mabi=64"
CONFIG_CPU_TYPE="octeonplus"
CONFIG_LINUX_5_4=y
CONFIG_DEFAULT_base-files=y
CONFIG_DEFAULT_busybox=y
CONFIG_DEFAULT_ca-bundle=y
CONFIG_DEFAULT_dnsmasq=y
CONFIG_DEFAULT_dropbear=y
CONFIG_DEFAULT_e2fsprogs=y
CONFIG_DEFAULT_firewall=y
CONFIG_DEFAULT_fstools=y
CONFIG_DEFAULT_ip6tables=y
CONFIG_DEFAULT_iptables=y
CONFIG_DEFAULT_kmod-gpio-button-hotplug=y
CONFIG_DEFAULT_kmod-ipt-offload=y
CONFIG_DEFAULT_kmod-leds-gpio=y
CONFIG_DEFAULT_kmod-of-mdio=y
CONFIG_DEFAULT_kmod-sfp=y
CONFIG_DEFAULT_kmod-usb-dwc3=y
CONFIG_DEFAULT_kmod-usb-storage-uas=y
CONFIG_DEFAULT_kmod-usb3=y
CONFIG_DEFAULT_libc=y
CONFIG_DEFAULT_libgcc=y
CONFIG_DEFAULT_libustream-wolfssl=y
CONFIG_DEFAULT_logd=y
CONFIG_DEFAULT_mkf2fs=y
CONFIG_DEFAULT_mtd=y
CONFIG_DEFAULT_netifd=y
CONFIG_DEFAULT_odhcp6c=y
CONFIG_DEFAULT_odhcpd-ipv6only=y
CONFIG_DEFAULT_opkg=y
CONFIG_DEFAULT_ppp=y
CONFIG_DEFAULT_ppp-mod-pppoe=y
CONFIG_DEFAULT_procd=y
CONFIG_DEFAULT_uci=y
CONFIG_DEFAULT_uclient-fetch=y
CONFIG_DEFAULT_urandom-seed=y
CONFIG_DEFAULT_urngd=y
CONFIG_AUDIO_SUPPORT=y
CONFIG_GPIO_SUPPORT=y
CONFIG_PCI_SUPPORT=y
CONFIG_PCIE_SUPPORT=y
CONFIG_USB_SUPPORT=y
CONFIG_BIG_ENDIAN=y
CONFIG_USES_DEVICETREE=y
CONFIG_USES_INITRAMFS=y
CONFIG_USES_SQUASHFS=y
CONFIG_ARCH_64BIT=y
CONFIG_mips64=y
CONFIG_ARCH="mips64"

#
# Target Images
#

And the resulting config.buildinfo in the folder: ~/openwrt/bin/targets/ath79/generic

CONFIG_TARGET_ath79=y
CONFIG_TARGET_ath79_generic=y
CONFIG_TARGET_ath79_generic_DEVICE_8dev_carambola2=y

What git clone address do you use?
Do you clone from github or git?

As far as I'm aware the make command only cares about .config. If you're saving a config file as anything else you aren't actually changing what will be built when you run make. You either need to use menuconfig to make changes and then save it as .config. Or rename your config file to .config before you run make.

target/linux/general and target/linux/octeon both contain a config-5.4/config-5.10

The $(TOPDIR)/.config are some target flags but mostly userspace packages and deps

Keep in mind that Any time you change something, you have to RE-RUN make menuconfig so it can set the deps for you.. Clarification: If you manually edit $(TOPDIR)/.config you have to re-run make menuconfig

Also, I'll welcome you to the nearly non-existent Octeon tree! We have cake!

Hint: Make sure you enable Kernel-space MIPS_FPU support as everything is soft-float and requires kernel fpu emulation to do anything fancy.

2 Likes

I have had ER4 for a year now with openwrt, but I am aware of the memory troubled future for this device.
I starting to be somewhat tired of this now, wrt3200acm was a driver blown, er4 is a driver blown…
Everything I have bought is driver blown…

I am now thinking of getting a raspberry pi or nanopi for future proof and build a 19” rack mount for it.
Nanopi at least seem to have crypto support.

Don't give up on it yet.. We are still trying to work thru what appears to be the multiple leaks.. It was reported a 5.10 revision helped at least fix some of it, but honestly, I've not been able to poke at it much (not that it would mean much anyway).

2 Likes

That is actually a little bit of this “compile from source” thing we are trying to accomplish here, only to be able to keep my “black box” alive as long as possible…
I really like the ER4, and it really got my OVPN tunnel moving.
So I really don't want to let it go.

1 Like

Those are not meant to be edited, unless you really know what you are doing. They the are the low-level kernel config.

The .config in the OpenWrt topdir is the main OpenWrt config file that can be edited by hand, or by "make menuconfig". It contains all package selections and config options.
(If you edit it by hand, it is good to run "make defconfig" after editing, so that the dependencies etc. are straightened up.

1 Like

If you have questions, feel free to hit me up here/DM or I'm always on the IRC channel with some others who know the arch

Yes, but at this point with this target, it needs to be done. They are building from source, so it gives them that latitude.. Although, it should be done via make kernel_menuconfig I suppose :smiley:

OpenWrt forced soft-float, which would be fine by the octeon targets have zero float support unless it's also enabled in the kernel .. Took forever for us to track that one down.

2 Likes

Yep. But doing that is maybe for the time after the build process first completes at all.

I still do not understand the troubles that the op is having with the basic config process and ath79/octeon difficulties in .config
Sounds like something wrong with the buildhost.

1 Like

I'd try:

make dirclean
git switch master
git fetch origin && git rebase origin/master
make download && make defconfig && make menuconfig and set it to octeon, save and exit.
make -j$(nproc-1) || make -j1 V=sc and see what it does?

I have selected the safe way of having completely different buildroot for each device and release. Sure it wastes disk space, but makes it also easier to test possibly problematic changes e.g. to busybox etc.

I have been building OpenWrt since 2011 for various devices, and for several branches. (Community builds for R7800 and WNDR3700, plus CPU frequency scaling for WRT3200ACM). As my build scripts publish all the source code changes for the build, I have wanted clarity. The source changes vary so much. E.g. setting the correct default wan interface for SQM varies a lot (before DSA), so sqm-scripts in the packages feed have different changes for ath79, ipq806x and mvebu.

2 Likes

What I have learned today so far is correct handling of the .config is not easy but very easy to get it wrong.

You might read

I keep a short recipe as a separate file, edit it for modifications, and always before build copy it to be the .config and expand it with "make defconfig"

2 Likes