Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| playground:playground [2022/12/19 04:46] – [Using the Image Builder] added odon-noda | playground:playground [2024/08/06 19:36] – testando mguima | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== PlayGround ====== | ====== PlayGround ====== | ||
| - | ~~NOTOC~~ | ||
| - | < | + | ====== Bootlogs ====== |
| - | The playground is for experimenting. Play around as you like!\\ | + | ==== OEM bootlog ==== |
| - | This page is for playing around and experimenting only, and can be deleted any time, therefore don't put anything here that shall last long time.\\ | + | < |
| - | Use the [[inbox: | + | < |
| + | ... TBD ... | ||
| + | </ | ||
| + | </ | ||
| - | Add your content below the line and **leave this note in place.** | + | ====== Bootlogs ====== |
| - | </WRAP> | + | === OpenWRT bootlog === |
| - | ---- | + | == System bootlog == |
| + | <WRAP bootlog> | ||
| + | < | ||
| + | ... TBD ... | ||
| + | </nowiki> | ||
| + | </ | ||
| - | ===== Template deviceinfo2 (model + version) ===== | ||
| - | |||
| - | Works for devices **with** version (RT-AC1200 v1): | ||
| - | {{wst> | ||
| - | Works for devices **with** version (RT-AC1200 v2): | ||
| - | {{wst> | ||
| - | |||
| - | Does not work for devices **without** version (WR6202): | ||
| - | {{wst> | ||
| - | |||
| - | ===== Template deviceinfo (model only) ===== | ||
| - | |||
| - | Works work for devices **without** version (WR6202): | ||
| - | {{wst> | ||
| - | |||
| - | Does not work for devices **with** version (RT-AC1200 v1) -> always shows both, v1+v2: | ||
| - | {{wst> | ||
| - | Does not work for devices **with** version (RT-AC1200 v2) -> always shows both, v1+v2: | ||
| - | {{wst> | ||
| - | Does not work for devices **with** version (RT-AC1200 without version) -> always shows both, v1+v2: | ||
| - | {{wst> | ||
| - | |||
| - | ===== Template Flash layout ===== | ||
| - | ^ [[toh: | ||
| - | ^ Layer0 | ||
| - | ^ Layer1 | ||
| - | ^ Layer2 | ||
| - | ^ <color magenta> | ||
| - | ^ filesystem | ||
| - | ^ Layer3 | ||
| - | ^ Size in KiB | ||
| - | ^ Name | **// | ||
| - | ^ <color magenta> | ||
| - | ^ filesystem | ||
| - | **'' | ||
| - | '' | ||
| - | |||
| - | ====== Using the Image Builder ====== | ||
| - | See also: | ||
| - | [[docs: | ||
| - | [[docs: | ||
| - | [[docs: | ||
| - | |||
| - | The Image Builder (previously called the Image Generator) is a pre-compiled environment suitable for creating custom images without the need for compiling them from source. | ||
| - | It downloads pre-compiled packages and integrates them in a single flashable image. | ||
| - | |||
| - | Doing so is useful if: | ||
| - | * you want to fit more packages in a small flash size | ||
| - | * you want to follow development snapshots | ||
| - | * your device has 32MB or less RAM and opkg does not work properly | ||
| - | * you want to mass-flash dozens of devices and you need a specific firmware setup | ||
| - | |||
| - | <WRAP important> | ||
| - | The Image Builder images are not identical to official images as they obtain pre-generated packages. | ||
| - | When recent/ | ||
| - | </ | ||
| - | |||
| - | ===== Prerequisites ===== | ||
| - | <WRAP important> | ||
| - | * The Image Builder runs only in 64-bit Linux. You can however run a 64-bit Linux in PC or VM, e.g. VirtualBox, even from 32-bit Windows. | ||
| - | * The Image Builder has similar prerequisites as the [[docs: | ||
| - | </ | ||
| - | |||
| - | Example dependencies in the most common distros: | ||
| - | |||
| - | ==== Arch / Manjaro ==== | ||
| - | <code bash> | ||
| - | sudo pacman -S --needed base-devel ncurses zlib gawk git gettext \ | ||
| - | openssl libxslt wget unzip python | ||
| - | </ | ||
| - | |||
| - | ==== CentOS / Fedora ==== | ||
| - | <code bash> | ||
| - | sudo dnf install git gawk gettext ncurses-devel zlib-devel \ | ||
| - | openssl-devel libxslt wget which @c-development @development-tools \ | ||
| - | @development-libs zlib-static which python3 | ||
| - | </ | ||
| - | |||
| - | ==== Debian / Ubuntu ==== | ||
| - | <code bash> | ||
| - | sudo apt install build-essential libncurses5-dev libncursesw5-dev \ | ||
| - | zlib1g-dev gawk git gettext libssl-dev xsltproc rsync wget unzip python | ||
| - | </ | ||
| - | |||
| - | ===== Obtaining the Image Builder ===== | ||
| - | You can download an archive that contains the **Image Builder**, it is usually located in the same download page where you find the firmware image for your device. | ||
| - | |||
| - | For example, this is the page where you can download all firmware images for **ath79/ | ||
| - | [[https:// | ||
| - | and you will find a **openwrt-imagebuilder-ath79-generic.Linux-x86_64.tar.xz** archive with the image builder in it. | ||
| - | Also, it is always created by the build system because it is needed to create the image file. | ||
| - | If the option " | ||
| - | |||
| - | ===== Usage ===== | ||
| - | <WRAP important> | ||
| - | All operations should be performed with a non-root user account. | ||
| - | </ | ||
| - | |||
| - | Unpack the archive and change the working directory: | ||
| - | |||
| - | <code bash> | ||
| - | tar -J -x -f openwrt-imagebuilder-*.tar.xz | ||
| - | cd openwrt-imagebuilder-*/ | ||
| - | </ | ||
| - | |||
| - | The image building can be customized with the following variables: | ||
| - | |||
| - | ^ Variable ^ Description ^ | ||
| - | | '' | ||
| - | | '' | ||
| - | | '' | ||
| - | | '' | ||
| - | | '' | ||
| - | | '' | ||
| - | |||
| - | Run '' | ||
| - | |||
| - | ==== Selecting profile ==== | ||
| - | The '' | ||
| - | |||
| - | <code bash> | ||
| - | PROFILE=" | ||
| - | </ | ||
| - | |||
| - | Run '' | ||
| - | |||
| - | ==== Selecting packages ==== | ||
| - | The '' | ||
| - | By default (empty PACKAGES variable) the Image Builder will create a minimal image with device-specific kernel and drivers, uci, ssh, switch, firewall, ppp and ipv6 support. | ||
| - | |||
| - | <code bash> | ||
| - | PACKAGES=" | ||
| - | </ | ||
| - | |||
| - | The example above will include pkg1, pkg2, pkg3, and exclude pkg4, pkg5, pkg6, note the " | ||
| - | |||
| - | You don't need to list all dependencies of the packages you need in this list, the Image Builder uses '' | ||
| - | |||
| - | The list of currently installed packages on your device can be obtained with the following command: | ||
| - | |||
| - | <code bash> | ||
| - | echo $(opkg list-installed | sed -e " | ||
| - | </ | ||
| - | |||
| - | <WRAP important> | ||
| - | Many devices are limited in storage capacity and there is no guarantee that the build system will detect when you have added too many packages to fit into the device storage space, which may render the device unbootable if installed. | ||
| - | If in doubt, do not go overboard. | ||
| - | Use what you had installed on the device last as a guide or create a minimal image first, install it to the device and test what you would like to add first. | ||
| - | Consider removing unnecessary packages to [[docs: | ||
| - | </ | ||
| - | |||
| - | In addition ABI versioned packages such as '' | ||
| - | You may get compile errors when these are provided as packages. | ||
| - | To avoid issues you should omit them from image builder and let the correct versions be installed via package dependencies. | ||
| - | The '' | ||
| - | |||
| - | ==== Custom packages ==== | ||
| - | If there is a custom package or ipk you would prefer to use create a '' | ||
| - | |||
| - | ==== Custom files ==== | ||
| - | The '' | ||
| - | This is especially useful if you need to change the network configuration from default before flashing, or if you are preparing an image for mass-flashing many devices. | ||
| - | |||
| - | <code bash> | ||
| - | FILES=" | ||
| - | </ | ||
| - | |||
| - | The '' | ||
| - | |||
| - | It is strongly recommended to use [[docs: | ||
| - | This helps minimize conflicts with auto-generated settings which can change between versions. | ||
| - | |||
| - | see: [[: | ||
| - | |||
| - | ==== Building image ==== | ||
| - | After you select the appropriate profile, packages and custom files, pass it to the '' | ||
| - | |||
| - | <code bash> | ||
| - | make image PROFILE=" | ||
| - | </ | ||
| - | |||
| - | After the make command is finished, the generated images are stored in the bin/// | ||
| - | |||
| - | The built image will be found under the subdirectory '' | ||
| - | |||
| - | ==== Cleaning up ==== | ||
| - | To clean up temporary build files and generated images, use the '' | ||
| - | |||
| - | ==== Examples ==== | ||
| - | The following example shows: | ||
| - | * Creating the directory for the configuration files. | ||
| - | * Using '' | ||
| - | * Generating an image for WL500GP with custom packages and '' | ||
| - | |||
| - | <code bash> | ||
| - | mkdir -p files/ | ||
| - | scp root@192.168.1.1:/ | ||
| - | scp root@192.168.1.1:/ | ||
| - | scp root@192.168.1.1:/ | ||
| - | make image PROFILE=" | ||
| - | </ | ||
| - | |||
| - | ===== Troubleshooting ===== | ||
| - | - Did you run everything as a non-root user? | ||
| - | - Check the logged output, are there package issues (conflicts, improper names)? | ||
| - | - Check the logged output, did you exceed maximum space? | ||
| - | - Check the logged output, are there other obvious errors? | ||
| - | - Wait a few hours/ | ||
| - | - Verify you have a supported OS, prerequisites, | ||
| - | |||
| - | ===== Extras ===== | ||
| - | The topics below go beyond simple usage and aimed at developers and advanced users. | ||
| - | |||
| - | ==== Detailed help ==== | ||
| - | See also: [[https:// | ||
| - | |||
| - | Getting detailed help: | ||
| - | |||
| - | < | ||
| - | # make help | ||
| - | |||
| - | Available Commands: | ||
| - | help: This help text | ||
| - | info: Show a list of available target profiles | ||
| - | clean: | ||
| - | image: | ||
| - | |||
| - | Building images: | ||
| - | By default 'make image' will create an image with the default | ||
| - | target profile and package set. You can use the following parameters | ||
| - | to change that: | ||
| - | |||
| - | make image PROFILE="< | ||
| - | make image PACKAGES="< | ||
| - | make image FILES="< | ||
| - | make image BIN_DIR="< | ||
| - | make image EXTRA_IMAGE_NAME="< | ||
| - | make image DISABLED_SERVICES="< | ||
| - | make image ADD_LOCAL_KEY=1 # store locally generated signing key in built images | ||
| - | |||
| - | Print manifest: | ||
| - | List " | ||
| - | You can use the following parameters: | ||
| - | |||
| - | make manifest PROFILE="< | ||
| - | make manifest PACKAGES="< | ||
| - | make manifest STRIP_ABI=1 # remove ABI version from printed package names | ||
| - | </ | ||
| - | |||
| - | ==== Available profiles ==== | ||
| - | Listing available profiles: | ||
| - | |||
| - | < | ||
| - | # make info | ||
| - | |||
| - | Available Profiles: | ||
| - | |||
| - | Default: | ||
| - | Default Profile | ||
| - | Packages: kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport | ||
| - | ai-br100: | ||
| - | Aigale Ai-BR100 | ||
| - | Packages: kmod-usb2 kmod-usb-ohci | ||
| - | rp-n53: | ||
| - | Asus RP-N53 | ||
| - | Packages: | ||
| - | rt-n14u: | ||
| - | Asus RT-N14u | ||
| - | Packages: | ||
| - | whr-1166d: | ||
| - | Buffalo WHR-1166D | ||
| - | Packages: | ||
| - | whr-300hp2: | ||
| - | Buffalo WHR-300HP2 | ||
| - | Packages: | ||
| - | ... | ||
| - | </ | ||
| - | |||
| - | ==== Building the Image Builder with all packages inside ==== | ||
| - | It is possible to use a buildroot to create your own Image Builder and integrate in it all packages so it will be able to generate images without downloading packages. | ||
| - | |||
| - | In the graphical configuration, | ||
| - | You can [[docs: | ||
| - | |||
| - | Don't call '' | ||
| - | |||
| - | ==== Adding package repositories ==== | ||
| - | The Image Builder you download from the OpenWrt pages is already configured to download any non-default packages from official repositories. | ||
| - | The package sources are configured in the '' | ||
| - | Sources are specified in //opkg// native config format. | ||
| - | This can be either the official package repositories or custom generated repositories. | ||
| - | |||
| - | An example of the contents of the '' | ||
| - | |||
| - | <code bash> | ||
| - | ## Place your custom repositories here, they must match the architecture and version. | ||
| - | # src/gz %n http:// | ||
| - | # src custom file:/// | ||
| - | |||
| - | ## Remote package repositories | ||
| - | src/gz openwrt_core http:// | ||
| - | src/gz openwrt_base http:// | ||
| - | src/gz openwrt_luci http:// | ||
| - | src/gz openwrt_packages http:// | ||
| - | src/gz openwrt_routing http:// | ||
| - | src/gz openwrt_telephony http:// | ||
| - | |||
| - | ## This is the local package repository, do not remove! | ||
| - | src imagebuilder file: | ||
| - | </ | ||
| - | |||
| - | The '' | ||
| - | |||
| - | If you want to add a custom local repository, copy the '' | ||
| - | If you have problems with using you local repository because the " | ||
| - | |||
| - | If you have custom repositories online, copy and modify the '' | ||
| - | |||
| - | NOTE: if you want to override packages coming from an existing feed, you must write your custom feed ABOVE the line of the package feed containing the packages you want to override, as shown in the examples above. | ||
| - | |||
| - | ==== Restricting root access ==== | ||
| - | Create a non-privileged admin user and lock root password. | ||
| - | Configure privilege elevation with sudo. | ||
| - | Set up key-based authentication and disable password authentication for Dropbear. | ||
| - | |||
| - | <code bash> | ||
| - | mkdir -p files/ | ||
| - | cat << " | ||
| - | USER_NAME=" | ||
| - | USER_GROUP=" | ||
| - | USER_SSHPUB=" | ||
| - | USER_SHELL="/ | ||
| - | SUDO_USER=" | ||
| - | SUDO_GROUP=" | ||
| - | SUDO_GID=" | ||
| - | uci set dropbear.@dropbear[0].PasswordAuth=" | ||
| - | uci set dropbear.@dropbear[0].RootPasswordAuth=" | ||
| - | uci commit dropbear | ||
| - | / | ||
| - | passwd -l " | ||
| - | groupadd -r -g " | ||
| - | touch / | ||
| - | cat << EOI > / | ||
| - | %${SUDO_GROUP} ALL=(ALL) ALL | ||
| - | EOI | ||
| - | groupadd " | ||
| - | useradd -m -g " | ||
| - | -s " | ||
| - | passwd -d " | ||
| - | USER_HOME=" | ||
| - | mkdir -p " | ||
| - | cat << EOI > " | ||
| - | ${USER_SSHPUB} | ||
| - | EOI | ||
| - | chown -R " | ||
| - | chmod -R go= " | ||
| - | EOF | ||
| - | make image FILES=" | ||
| - | </ | ||
| - | |||
| - | ==== Adding/ | ||
| - | |||
| - | <WRAP important> | ||
| - | Examples below may contain version dependent / legacy information and are for informational purposes. They are very low level so expect to have a good level of skill and familiarity with the ImageBuilder / OpenWrt in general. | ||
| - | </ | ||
| - | |||
| - | The image building is tied to the profile names. | ||
| - | If you add a new profile without also adding an appropriate macro to the image-generation Makefile, no suitable firmware file will get generated when using the custom profile. | ||
| - | Remove the ''/ | ||
| - | |||
| - | The location of the profiles for the pre-compiled package for // | ||
| - | |||
| - | Remarkably, all that needs to be done to add a new profile, is to add a new file to the // | ||
| - | //While this may have been the case in earlier releases, for 17.01, it appears that manual editing of '' | ||
| - | |||
| - | Here is what the // | ||
| - | |||
| - | <code bash> | ||
| - | define Profile/ | ||
| - | NAME: | ||
| - | PACKAGES: | ||
| - | endef | ||
| - | |||
| - | define Profile/ | ||
| - | Package set compatible with hardware using Broadcom BCM43xx cards | ||
| - | endef | ||
| - | $(eval $(call Profile, | ||
| - | </ | ||
| - | |||
| - | Alternately edit the hidden .profile.mk file at the top level directory of the image builder and manually add the names of the desired packages to be added to the output image. | ||
| - | An "ls -a" will reveal the files hidden in the various directories. | ||
| - | |||
| - | ==== Removing useless files from firmware ==== | ||
| - | <WRAP important> | ||
| - | This is not a standard feature of the Image Builder. | ||
| - | |||
| - | It is highly recommended that you test file removal prior to incorporating such changes at the image builder level or that you have low level means to recover a device before attempting this type of mod, as bricking / non booting may result. | ||
| - | |||
| - | Note that it requires patching of the '' | ||
| - | |||
| - | It is based on older Chaos Calmer era code... and not applicable to modern ImageBuilders but useful as a reference... | ||
| - | </ | ||
| - | |||
| - | Create file '' | ||
| - | |||
| - | <code bash> | ||
| - | / | ||
| - | / | ||
| - | / | ||
| - | / | ||
| - | </ | ||
| - | |||
| - | Patch Makefile: | ||
| - | |||
| - | <code diff> | ||
| - | ifneq ($(USER_FILES), | ||
| - | | ||
| - | endif | ||
| - | + | ||
| - | +ifneq ($(FILES_REMOVE), | ||
| - | + @echo | ||
| - | + @echo Remove useless files | ||
| - | + | ||
| - | + while read filename; do \ | ||
| - | + rm -rfv " | ||
| - | + done < $(FILES_REMOVE); | ||
| - | +endif | ||
| - | + | ||
| - | | ||
| - | | ||
| - | </ | ||
| - | |||
| - | Rebuild firmware: | ||
| - | |||
| - | <code bash> | ||
| - | make image \ | ||
| - | PROFILE=" | ||
| - | PACKAGES=" | ||
| - | FILES_REMOVE=" | ||
| - | </ | ||