Preparation: ------------ User/Group to be used: USER=maddes Download folder: Everything is only downloaded once, and doesn't get lost on a "make distclean". Saves download time, and also hdd space when used in several checkouts. mkdir ~${USER}/openwrt/downloads/ chown -R ${USER}:${USER} ~${USER}/openwrt/downloads Snapshots folder: Images from the official OpenWrt download site. mkdir ~${USER}/openwrt/snapshots/ chown -R ${USER}:${USER} ~${USER}/openwrt/snapshots Trunk folder: (most current) No extra feeds in here, for compiling new flash images quickly. mkdir ~${USER}/openwrt/trunk/ cd ~${USER}/openwrt/trunk/ ln -s ../downloads/ dl chown -R ${USER}:${USER} ~${USER}/openwrt/trunk Last release folder: No extra feeds in here, for compiling new flash images quickly. mkdir ~${USER}/openwrt/backfire/ cd ~${USER}/openwrt/backfire/ ln -s ../downloads/ dl chown -R ${USER}:${USER} ~${USER}/openwrt/backfire Get release config: wget -N http://downloads.openwrt.org/backfire/10.03/orion/OpenWrt.config mv OpenWrt.config ~${USER}/openwrt/orion-config-backfire Packages folders: (for testing compilation of all of them) With feeds, for compiling packages for a package repository or modified packages. mkdir ~${USER}/openwrt/packages/ cd ~${USER}/openwrt/packages/ ln -s ../downloads/ dl chown -R ${USER}:${USER} ~${USER}/openwrt/packages Older Trunk folders: (for testing specific revisions) mkdir ~${USER}/openwrt/trunk_r17264/ cd ~${USER}/openwrt/trunk_r17264/ ln -s ../downloads/ dl chown -R ${USER}:${USER} ~${USER}/openwrt/trunk_r17264 Enable scripts: chmod +x ~/openwrt/*.sh ================================================================================ Initial checkout: ----------------- cd ~/openwrt/trunk/ # - or - cd ~/openwrt/packages/ svn checkout svn://svn.openwrt.org/openwrt/trunk/ . ; \ printf '\a' #ring the bell when done # add own patches # last release (branch) cd ~/openwrt/backfire/ svn checkout svn://svn.openwrt.org/openwrt/branches/backfire/ . ; \ printf '\a' #ring the bell when done # add own patches # last release (tag) cd ~/openwrt/backfire-10.03/ svn checkout svn://svn.openwrt.org/openwrt/tags/backfire_10.03/ . ; \ printf '\a' #ring the bell when done # add own patches # specific revision cd ~/openwrt/trunk_r17264/ svn checkout -r 17264 svn://svn.openwrt.org/openwrt/trunk/ . ; \ printf '\a' #ring the bell when done # add own patches ================================================================================ Revision Infos: --------------- svn info . # - for packages - svn info feeds/packages svn info feeds/luci svn info feeds/xwrt Modifications: -------------- svn status . # - for packages - svn status feeds/packages svn status feeds/luci svn status feeds/xwrt Changes: -------- https://dev.openwrt.org/changeset/17650 http://code.google.com/p/x-wrt/source/detail?r=4787 TRAC templates: --------------- a) Trunk Trunk rev: [18456] (distcleaned before compilation)[[BR]] No other feeds installed b) Packages Trunk rev: [18456] (last distclean [?])[[BR]] Feed "packages" rev: same as trunk, all packages installed[[BR]] Feed "luci" rev: 5268, all packages installed[[BR]] Feed "xwrt" rev: 4802, all packages installed Build Environment: Debian 5.0 ================================================================================ Compilation: ------------ cd ~/openwrt/trunk/ # - or - cd ~/openwrt/packages/ # - or - cd ~/openwrt/backfire/ Reproduction: {{{ # --- distclean if wanted --- # backup dl directory to save download time, clean everything and restore dl directory mv dl dl_save ; \ make distclean ; \ mv dl_save dl ; \ printf '\a' #ring the bell when done # --- normal clean if wanted and not distclean chosed --- make clean ; \ scripts/feeds uninstall -a ; \ rm .config ; \ printf '\a' #ring the bell when done # --- get latest sources --- svn up ; \ # - for packages - scripts/feeds update packages ; \ scripts/feeds update luci ; \ scripts/feeds update xwrt ; \ # printf '\a' #ring the bell when done # add/check own patches # --- install feeds --- scripts/feeds uninstall -a ; \ # - for packages - scripts/feeds install -a -p packages ; \ scripts/feeds install -a -p luci ; \ scripts/feeds install -a -p xwrt ; \ # printf '\a' #ring the bell when done ### Prepare build . ../prepare_build.sh # --- define board and build type plus more for logfile and scripts --- BOARD='orion' # - or - BOARD='brcm-2.4' # - or - BOARD='brcm47xx' BIN_DIR=bin BIN_DIR=bin/${BOARD} # since r18640 (or with rules.r17264.patch) # for different kernel versions EXTRA='_2.6.32' # - or - EXTRA='+led' # - or - EXTRA= # get trunk revision and update opkg.conf accordingly REV="$(svn info -r COMMITTED | awk '/^Revision:/ { print $2 }')" ; \ sed -i.old -e "s/\/build_[^\/]*/\/build_${REV}${EXTRA}/" package/opkg/files/opkg.conf # check for own modifications to include in the log file name REV2="$(svnversion)" ; \ [ "${REV2: -1:1}" = "M" ] && REV="${REV}M" ; \ REV2= REVP= [ -d feeds/packages ] && { \ REVP="$(svn info -r COMMITTED feeds/packages | awk '/^Revision:/ { print $2 }')" ; \ REV2="$(svnversion feeds/packages)" ; \ [ "${REV2: -1:1}" = "M" ] && REVP="${REVP}M" ; \ REV2= ; \ REVP="(p${REVP})" ; \ } # --- ATTENTION!!! Issue a make clean before changing the build type --- # - for release build (incl. IPv6 support) - cp ../${BOARD}-config-release .config ; \ BUILDTYPE= # - or - cp ../${BOARD}-config-backfire .config ; \ BUILDTYPE= # - for mini build (incl. IPv6 support) - cp ../${BOARD}-config-mini .config ; \ BUILDTYPE=mini # - optional: if something is excluded #CONFPKG='# CONFIG_PACKAGE_kmod-ipsec is not set' ; \ #grep -e "${CONFPKG}" .config || echo "${CONFPKG}" >>.config ; \ #BUILDTYPE=${BUILDTYPE:=release}-ipsec # - optional: if kmod-tun shall be included CONFPKG='CONFIG_PACKAGE_kmod-tun=y' ; \ grep -e "${CONFPKG}" .config || echo "${CONFPKG}" >>.config ; \ BUILDTYPE=${BUILDTYPE:=release}+tun # --- first build ramdisk image for testing # create config IMGTYPE='ramdisk' # make menuconfig - A) RAMDISK build --> Target Images: ramdisk - B) for WRT350Nv2 --> Target System: Marvel Orion (ARM, Kernel 2.6.30) - B) for WRT54G --> Target System: BCR... (Mipsel, Kernel 2.6.28) - C) IPv6 support --> Global build settings: Enable IPv6 support in packages - D) for all - --> Global build settings: Select all packages by default --> Deselect modules/packages that are not in a release build: (see http://nbd.name/release-build) category: Network --> ebtables category: Network --> ebtables-utils category: Kernel Modules --> Netfilter Extensions --> kmod-ebtables others: enlightenment, etk, python-etk --> Deselect problematic modules/packages (if any): ./. - E) for debugging - --> Global build settings: Compile the kernel with symbol table information # --- then build squashfs image for flashing IMGTYPE= # create config make menuconfig - A) SQUAHSFS build --> Target Images: SquashFS image (default) ### Do build . ../do_build.sh # compile & create flash images mkdir -p ${BIN_DIR}; rm ${BIN_DIR}/* LOGFILE="${BIN_DIR}/compilelog.${BOARD}${BUILDTYPE:+.${BUILDTYPE}}${IMGTYPE:+.${IMGTYPE}}.${REV}${REVP}${EXTRA}.`date +%Y%m%d_%H%M%S`.log" ; \ script -f -c 'make V=99 IGNORE_ERRORS=m' "${LOGFILE}" ; \ bzip2 "${LOGFILE}" ; \ bzcat "${LOGFILE}.bz2" | grep '^ ERROR:' >"${BIN_DIR}/errors.${BOARD}${BUILDTYPE:+.${BUILDTYPE}}${IMGTYPE:+.${IMGTYPE}}.log" ; \ - for WRT350Nv2 - ../create_images_orion.sh "${IMGTYPE}" "${BUILDTYPE}" ; \ printf '\a' }}} ================================================================================ Patches: -------- (current) patch -p0 <../dropbear_init.patch (old) cp ~/openwrt/trunk/package/dropbear/files/dropbear.init ~/openwrt/trunk_r17264/package/dropbear/files/ patch -p0 <../orion_sysupgrade_platform_sh.5.patch patch -p0 <../orion_sysupgrade_mtd.2.patch patch -p0 <../orion_sysupgrade_mtd_wnr854t.1.patch svn add target/linux/orion/base-files/lib svn add target/linux/orion/patches/101-openwrt_partition_map_wnr854t.patch (current) patch -p0 <../webupgrade.builder.r18985.patch patch -p0 <../webupgrade.image_makefile_wrt350nv2.r18985.patch (old) patch -p0 <../opkg.r17264.patch patch -p0 <../webupgrade.builder.v21.patch patch -p0 <../webupgrade.tools_makefile.r17264.patch patch -p0 <../webupgrade.image_makefile_wrt350nv2.r17264.patch svn add tools/wrt350nv2-builder cd feeds/packages patch -p0 <../etherwake_uci.patch svn add net/etherwake/files patch -p0 <../sslh_init.patch cd ../.. cd feeds/luci cd ../.. cd feeds/xwrt #patch -p0 <../xwrt_wol.patch cd ../.. # cp ../002-iwlib_h_fix.patch ./package/wireless-tools/patches ================================================================================ Flashing images (within U-Boot and within Linux, Linux also with different mtd sizes) --------------- in U-Boot --------- Prepare network: (default 172.21.5.10, default server 172.21.5.30) setenv ipaddr 10.0.0.99 setenv serverip 10.0.0.1 Boot ramdisk build for testing: # --- ramdisk build --- tftpboot "openwrt-wrt350nv2-uImage.ramdisk" bootm Flashing Openwrt firmware: # Get flash rom tftpboot 0x400000 "openwrt-wrt350nv2-squashfs.img" # --- !!! ERASING ROOTFS !!! --- erase 0xff800000 0xfff4ffff protect off 0xff800000 0xfff4ffff cp.b 0x400000 0xff800000 cp.b 0x400000 0xff800000 0x270000 Flashing stock firmware: # Get flash rom tftpboot 0x400000 "wrt350n.bin" # - or - tftpboot 0x400000 "mtd0.orig.img" # --- !!! ERASING ROOTFS INCL. "eRcOmM" ID!!! --- erase 0xff800000 0xfff5ffff protect off 0xff800000 0xfff5ffff cp.b 0x400000 0xff800000 0x760000 # reboot machine reset in Linux -------- Notes: Avoid as much traffic as possible while flashing, e.g. close all connections to. the router (sftp/scp, ssh, web, etc.) or remove cables from the ports. After flashing and reboot wait at least a minute before reconnecting. If there are still connections problems after some minutess, first make check that the right ip is used (default: 192.168.1.1). Otherwise give it a 2nd try by powering off the router, wait some seconds, power on again, wait a minute and try to reconnect. Preparation: # check mtd sizes cat /proc/mtd ls -la /dev/mtdblock* # set values BOARD='orion' MACHINE='wrt350nv2' # #BUILDTYPE= # - or - #BUILDTYPE='mini+tun' # - or - BUILDTYPE='snapshot' # IMGTYPE='squashfs' Flashing via sysupgrade: (!!! HIGHLY RECOMMENDED !!!) If sysupgrade is in the installed build, then just do: sysupgrade -v /tmp/openwrt-${MACHINE}-${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.img Flashing via dd with same mtd kernel size: # flash dd if="/tmp/openwrt-${MACHINE}-uImage${BUILDTYPE:+.${BUILDTYPE}}${IMGTYPE:+.${IMGTYPE}}.padded" of=/dev/mtdblock0 ; printf '\a' #ring the bell when done sync ; dd if="/tmp/root.${IMGTYPE}.${MACHINE}.${BUILDTYPE}" of=/dev/mtdblock1 ; rc=$? ; \ [ ${rc} -eq 0 ] && reboot ; printf '\a' ; [ ${rc} -eq 0 ] && exit Flashing via dd with different mtd kernel sizes: !!! PADDED IMAGES HIGHLY RECOMMENDED !!! # set values OLDKERNELSIZE='0x00120000' # - or - OLDKERNELSIZE='0x001A0000' # flash sync ; dd if="/tmp/img.${MACHINE}.${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.${OLDKERNELSIZE}.mtd0" of=/dev/mtdblock0 ; rc=$? ; \ [ ${rc} -eq 0 ] && { dd if="/tmp/img.${MACHINE}.${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.${OLDKERNELSIZE}.mtd1" of=/dev/mtdblock1 ; rc=$? ; } ; \ [ ${rc} -eq 0 ] && reboot ; printf '\a' ; [ ${rc} -eq 0 ] && exit Flashing on stock firmware: !!! PADDED IMAGES HIGHLY RECOMMENDED !!! sync ; dd if="/tmp/openwrt-${MACHINE}-${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.padded.img" of=/dev/mtdblock0 ; rc=$? ; \ [ ${rc} -eq 0 ] && reboot ; printf '\a' ; [ ${rc} -eq 0 ] && exit ================================================================================ Split OpenWrt snapshot builds into mtd images (no compiling needed) --------------------------------------------- cd ~/openwrt/snapshots/ # define vars for this run BOARD='orion' MACHINE='wrt350nv2' BUILDTYPE='snapshot' IMGTYPE='squashfs' KERNELMTDSIZE='0x00100000' TODAY=`date +%Y%m%d` # create dir to hold today's downloads for the board mkdir -p ${BOARD}-${TODAY}/bin || rm ${BOARD}-${TODAY}/bin/* cd ${BOARD}-${TODAY}/bin # get files for device and board wget "http://downloads.openwrt.org/snapshots/trunk/${BOARD}/openwrt-${BOARD}-${IMGTYPE}.img" wget "http://downloads.openwrt.org/snapshots/trunk/${BOARD}/openwrt-${MACHINE}-uImage" wget "http://downloads.openwrt.org/snapshots/trunk/${BOARD}/openwrt-${MACHINE}-${IMGTYPE}.img" wget "http://downloads.openwrt.org/snapshots/trunk/${BOARD}/openwrt-${MACHINE}-${IMGTYPE}-webupgrade.img" # rename general board image mv "openwrt-${BOARD}-${IMGTYPE}.img" "openwrt-${BOARD}-${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.img" # extract rootfs from general board image # normally it's already padded to a 64k or 128k blocksize dd if="openwrt-${BOARD}-${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.img" of="root.${IMGTYPE}.${BOARD}.${BUILDTYPE}" bs=$(( ${KERNELMTDSIZE} )) skip=1 # rename and pad uImage mv "openwrt-${MACHINE}-uImage" "openwrt-${MACHINE}-uImage.${IMGTYPE}.${BUILDTYPE}" dd if="openwrt-${MACHINE}-uImage.${IMGTYPE}.${BUILDTYPE}" of="openwrt-${MACHINE}-uImage.${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.padded" bs=$(( ${KERNELMTDSIZE} )) conv=sync # rename machine image mv "openwrt-${MACHINE}-${IMGTYPE}.img" "openwrt-${MACHINE}-${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.img" # rename machine webupgrade image mv "openwrt-${MACHINE}-${IMGTYPE}-webupgrade.img" "openwrt-${MACHINE}-${IMGTYPE}-webupgrade${BUILDTYPE:+.${BUILDTYPE}}.img" # create machine image if not present, by concatenating machine uImage and general rootfs [ ! -f "openwrt-${MACHINE}-${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.img" ] && \ cat "openwrt-${MACHINE}-uImage.${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.padded" "root.${IMGTYPE}.${BOARD}.${BUILDTYPE}" >"openwrt-${MACHINE}-${IMGTYPE}${BUILDTYPE:+.${BUILDTYPE}}.img" cd .. # create further images if wanted ../create_images_orion.sh "${IMGTYPE}" "${BUILDTYPE}" ================================================================================ Split Linksys firmware image into mtd images -------------------------------------------- use script "extract_firmware_wrt350nv2.sh" ~/openwrt/extract_firmware_wrt350nv2.sh WRT mv wrt350n.bin wrt350n.org.bin mv wrt350n.zip wrt350n.org.zip ~/openwrt/trunk/staging_dir/host/bin/wrt350nv2-builder -v [-f 0x2017] -z wrt350n.org.zip image.img diff -s image.img WRT ~/openwrt/trunk/staging_dir/host/bin/wrt350nv2-builder -v [-f 0x2017] -b ../wrt350nv2.par diff -s wrt350n.bin wrt350n.org.bin ================================================================================ Variables during creation of image files ---------------------------------------- KDIR=build_dir/linux-orion_generic LINUX_DIR=build_dir/linux-orion_generic/linux-2.6.30.5 TARGET_DIR=build_dir/target-arm_uClibc-0.9.30.1/root-orion BIN_DIR=bin TMP_DIR=tmp STAGING_DIR_HOST=staging_dir/host