Building firmware for TL-WR841ND

im trying to build a firmware for tl-wr841nd v7, i am just using it as router, using wan port. i don't need ipv6 , or anything just luci with dns set options & schedule tasks nothing else is needed. i mean no graph and other load things.
The command im trying is: make -j1 image PROFILE=TLWR841 \ PACKAGES=“uhttpd uhttpd-mod-ubus libiwinfo-lua luci-base \ luci-app-firewall luci-mod-admin-full luci-theme-bootstrap \ ppp ppp-mod-pppoe ip6tables odhcp6c \ kmod-ipv6 kmod-ip6tables -dhcpd-ipv6only”

i tried to fix it by reading 3-4 documents but still i can't fix this error:

~/Downloads/openwrt-imagebuilder-18.06.9-ar71xx-tiny.Linux-x86_64$ make -j1 image PROFILE=TLWR841 \ PACKAGES=“uhttpd uhttpd-mod-ubus libiwinfo-lua luci-base \ luci-app-firewall luci-mod-admin-full luci-theme-bootstrap \ -ppp -ppp-mod-pppoe -ip6tables -odhcp6c \ -kmod-ipv6 -kmod-ip6tables -odhcpd-ipv6only”
make: invalid option -- '-'
make: invalid option -- '6'
make: invalid option -- 'a'
Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  --eval=STRING               Evaluate STRING as a makefile statement.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from recipes.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any recipe; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -O[TYPE], --output-sync[=TYPE]
                              Synchronize output of parallel jobs by TYPE.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no recipe; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo recipes.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  --trace                     Print tracing information.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.

This program built for x86_64-pc-linux-gnu
Report bugs to <bug-make@gnu.org>
# GNU Make 4.2.1
# Built for x86_64-pc-linux-gnu
# Copyright (C) 1988-2016 Free Software Foundation, Inc.
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.

# Make data base, printed on Sun Jan  3 23:50:08 2021

# Variables

# environment
DESKTOP_SESSION = /usr/share/xsessions/plasma
# environment
KONSOLE_DBUS_WINDOW = /Windows/1
# default
.SHELLFLAGS := -c
# environment
XDG_SESSION_CLASS = user
# environment
XDG_SESSION_TYPE = x11
# environment
XAUTHORITY = /home/blohsh/.Xauthority
# environment
XMODIFIERS = @im=ibus
# environment
SHELL = /bin/bash
# environment
_ = /usr/bin/make
# environment
QT_AUTO_SCREEN_SCALE_FACTOR = 0
# environment
GNUMAKEFLAGS := 
# environment
XDG_DATA_DIRS = /usr/share:/usr/share:/usr/local/share
# environment
DBUS_SESSION_BUS_ADDRESS = unix:path=/run/user/1000/bus
# environment
CLUTTER_IM_MODULE = ibus
# environment
LC_NAME = en_US.UTF-8
# environment
PAM_KWALLET5_LOGIN = /run/user/1000/kwallet5.socket
# environment
XDG_SESSION_PATH = /org/freedesktop/DisplayManager/Session1
# environment
PATH = /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
# environment
GPG_AGENT_INFO = /run/user/1000/gnupg/S.gpg-agent:0:1
# environment
XCURSOR_THEME = breeze_cursors
# environment
SESSION_MANAGER = local/blohsh:@/tmp/.ICE-unix/1098,unix/blohsh:/tmp/.ICE-unix/1098
# environment
XDG_RUNTIME_DIR = /run/user/1000
# environment
WINDOWID = 106954759
# environment
KONSOLE_PROFILE_NAME = Default
# environment
LC_NUMERIC = en_US.UTF-8
# environment
PROFILEHOME = 
# default
.FEATURES := target-specific order-only second-expansion else-if shortest-stem undefine oneshell archives jobserver output-sync check-symlink load
# environment
LS_COLORS = rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
# environment
XDG_SESSION_DESKTOP = KDE
# environment
SSH_AUTH_SOCK = /tmp/ssh-ykM1dNcSfoWd/agent.855
# environment
DISPLAY = :0
# environment
GTK_IM_MODULE = ibus
# environment
PWD = /home/blohsh/Downloads/openwrt-imagebuilder-18.06.9-ar71xx-tiny.Linux-x86_64
# environment
KDE_SESSION_VERSION = 5
# default
.LOADED := 
# environment
XDG_SEAT = seat0
# environment
SSH_AGENT_PID = 924
# environment
GTK_MODULES = gail:atk-bridge
# environment
HOME = /home/blohsh
# environment
LOGNAME = blohsh
# environment
KDE_FULL_SESSION = true
# environment
XDG_VTNR = 7
# environment
LC_TIME = en_US.UTF-8
# environment
COLORTERM = truecolor
# environment
KONSOLE_DBUS_SESSION = /Sessions/1
# default
MAKECMDGOALS := image uhttpd-mod-ubus libiwinfo-lua luci-base  luci-app-firewall luci-mod-admin-full luci-theme-bootstrap  -ppp  -kmod-ipv6
# environment
QT_IM_MODULE = ibus
# environment
SHLVL = 1
# environment
XDG_SESSION_ID = 3
# environment
USER = blohsh
# environment
LC_MONETARY = en_US.UTF-8
# environment
XDG_CURRENT_DESKTOP = KDE
# environment
LC_TELEPHONE = en_US.UTF-8
# environment
OLDPWD = /home/blohsh/Downloads
# default
.VARIABLES := 
# command line
PROFILE = TLWR841
# environment
LANGUAGE = 
# environment
XDG_SEAT_PATH = /org/freedesktop/DisplayManager/Seat0
# environment
SHELL_SESSION_ID = 435fbe661ba348bda62036836f3aa68c
# environment
LC_PAPER = en_US.UTF-8
# command line
PACKAGES = “uhttpd
# environment
QT_ACCESSIBILITY = 1
# environment
COLORFGBG = 15;0
# environment
LC_MEASUREMENT = en_US.UTF-8
# environment
QT4_IM_MODULE = ibus
# environment
GS_LIB = /home/blohsh/.fonts
# environment
KONSOLE_DBUS_SERVICE = :1.82
# environment
LC_IDENTIFICATION = en_US.UTF-8
# default
.RECIPEPREFIX := 
# environment
LC_ADDRESS = en_US.UTF-8
# environment
LANG = en_US.UTF-8
# environment
TERM = xterm-256color
# environment
KDE_SESSION_UID = 1000
# variable set hash-table stats:
# Load=73/1024=7%, Rehash=0, Collisions=1/92=1%

# Pattern-specific Variable Values

# No pattern-specific variable values.

# Directories


# No files, no impossibilities in 0 directories.

# Implicit Rules

# No implicit rules.

# Files

# Not a target:
uhttpd-mod-ubus:
#  Command line target.
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.

# Not a target:
 -ppp:
#  Command line target.
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.

# Not a target:
luci-base:
#  Command line target.
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.

# Not a target:
libiwinfo-lua:
#  Command line target.
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.

# Not a target:
luci-theme-bootstrap:
#  Command line target.
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.

# Not a target:
image:
#  Command line target.
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.

# Not a target:
luci-mod-admin-full:
#  Command line target.
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.

# Not a target:
 -kmod-ipv6:
#  Command line target.
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.

# Not a target:
 luci-app-firewall:
#  Command line target.
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.

# files hash-table stats:
# Load=9/1024=1%, Rehash=0, Collisions=0/9=0%
# VPATH Search Paths

# No 'vpath' search paths.

# No general ('VPATH' variable) search path.

# strcache buffers: 1 (0) / strings = 13 / storage = 169 B / avg = 13 B
# current buf: size = 8162 B / used = 169 B / count = 13 / avg = 13 B

# strcache performance: lookups = 22 / hit rate = 40%
# hash-table stats:
# Load=13/8192=0%, Rehash=0, Collisions=0/22=0%
# Finished Make data base on Sun Jan  3 23:50:08 2021

Take out the backslashes. Have the command and parameters all on one line.

There should be a - before each package you don't want, like all the ones related to IPV6. Also ppp is rather large it should be deleted unless you need it.

thanks i made a firmware. it is showing like 2.0 Mb in console, and in tmp directory i see a 3.2Mb and 3.8Mb file. 3.8 is factory.bin and 3.2 is sysupgrade.bin, im currently using original firmware of tplink which file should i load? and i thought i would be saving enough space.. but its still 3.8Mb
i run this
make image PROFILE=tl-wr841-v7 PACKAGES="uhttpd uhttpd-mod-ubus luci-base -luci-app-firewall luci-mod-admin-full luci-theme-bootstrap -ppp -ppp-mod-pppoe -ip6tables -odhcp6c -kmod-ipv6 -kmod-ip6tables -odhcpd-ipv6only -iptables -opkg"

2036862 bytes (2.0 MB, 1.9 MiB) copied, 0.253956 s, 8.0 MB/s
[mktplinkfw] rootfs offset aligned to 0x1375176
[mktplinkfw] firmware file "/home/blohsh/Downloads/openwrt-imagebuilder-18.06.9-ar71xx-tiny.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_tiny/tmp/openwrt-18.06.9-ar71xx-tiny-tl-wr841-v7-squashfs-sysupgrade.bin.new" completed
3978+1 records in
3978+1 records out
2036862 bytes (2.0 MB, 1.9 MiB) copied, 0.250171 s, 8.1 MB/s
[mktplinkfw] rootfs offset aligned to 0x1375176
[mktplinkfw] firmware file "/home/blohsh/Downloads/openwrt-imagebuilder-18.06.9-ar71xx-tiny.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_tiny/tmp/openwrt-18.06.9-ar71xx-tiny-tl-wr841-v7-squashfs-factory.bin.new" completed
padding image to 00200000
padding image to 001f2000
padding image to 001f4000
padding image to 00200000
16+1 records in
17+0 records out
2228224 bytes (2.2 MB, 2.1 MiB) copied, 0.070716 s, 31.5 MB/s

Use the factory image to install over factory firmware. Factory images for that model are always padded out with empty space to the full flash. You will have some space on the drive after installing.

ok i installed factory image, but how can i check flash memory now? because i cannot see software option in luci where i can see flash memory and free left.
i used these packages:

PACKAGES=“uhttpd uhttpd-mod-ubus libiwinfo-lua \ luci-base luci-app-firewall luci-mod-admin-full \ luci-theme-bootstrap zram-swap \ -ppp -ppp-mod-pppoe -iptables -ip6tables -odhcp6c -kmod-ipv6 \ -kmod-ip6tables -odhcpd-ipv6only -odhcpd -opkg”

You've removed opkg, which is the program that installs packages at run-time, driving the Software page. This is appropriate for an image builder build since you can instead make a new image with the packages you want.

Without the Software page I think the only way to check disk space is CLI commands like df.

its hard to understand for me can you please tell me how much is used? my router have 4mb flash only.

:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 2304      2304         0 100% /rom
tmpfs                    13908       480     13428   3% /tmp
/dev/mtdblock3             320       244        76  76% /overlay
overlayfs:/overlay         320       244        76  76% /
tmpfs                      512         0       512   0% /dev


/overlay is where files can be written. The 320 kB total space is what is left in the flash chip after the image is installed. That really isn't enough. Take some more stuff out to get to 512 or more.

"Available" needs to always be over 64 (kB) for the file system to work at all. This is because empty space is created by erasing blocks which are 64 kB large. It's at 76 now, that is not good.

:confused: i tried my best to save space. according to docs. can you help me? which more packages should i remove? i just use it as a router on wan port. i don't need ipv6 or iptables or graphs or logs or firewall pppoe nothing. i just need luci to edit wifi channels and ssid password thats all.. even i don't need shell access.

The easiest way to save space: Remove LuCI, configure your device via ssh.

1 Like

ok i tried:

make image \
    PROFILE=tl-wr841-v7 \
    PACKAGES="-ppp -ppp-mod-pppoe -ip6tables -odhcp6c -kmod-ipv6 -kmod-ip6tables -odhcpd-ipv6only"

but still the filesize of "openwrt-18.06.9-ar71xx-tiny-tl-wr841-v7-squashfs-factory.bin" is 3.8MiB
which is located in "/home/blohsh/Downloads/openwrt-imagebuilder-18.06.9-ar71xx-tiny.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ar71xx_tiny/tmp/"