Browse Source

Fresh pull from upstream 17.01 branch

RISCi_ATOM 2 years ago
parent
commit
b1426a23c6
100 changed files with 3018 additions and 1863 deletions
  1. 1 1
      Makefile
  2. 12 2
      config/Config-build.in
  3. 1 1
      config/Config-devel.in
  4. 0 1
      config/Config-images.in
  5. 1 1
      config/Config-kernel.in
  6. 2 2
      include/autotools.mk
  7. 4 0
      include/cmake.mk
  8. 0 3
      include/download.mk
  9. 1 1
      include/feeds.mk
  10. 8 1
      include/host-build.mk
  11. 1 1
      include/image-commands.mk
  12. 14 2
      include/image.mk
  13. 1 1
      include/kernel-build.mk
  14. 3 3
      include/kernel-version.mk
  15. 2 0
      include/package-ipkg.mk
  16. 9 1
      include/rootfs.mk
  17. 6 5
      include/target.mk
  18. 3 2
      package/base-files/Makefile
  19. 1 1
      package/base-files/files/etc/init.d/system
  20. 18 0
      package/base-files/files/etc/iproute2/rt_protos
  21. 1 0
      package/base-files/files/etc/openwrt_release
  22. 1 1
      package/base-files/files/etc/uci-defaults/13_fix_group_user
  23. 1 1
      package/base-files/files/lib/preinit/10_sysinfo
  24. 9 3
      package/base-files/files/sbin/wifi
  25. 1 0
      package/base-files/files/usr/lib/os-release
  26. 3 3
      package/base-files/image-config.in
  27. 62 0
      package/boot/apex/Makefile
  28. 20 0
      package/boot/apex/patches/001-compile_fix.patch
  29. 23 0
      package/boot/apex/patches/100-openwrt_nslu2_armeb_config.patch
  30. 23 0
      package/boot/apex/patches/120-openwrt_nslu2_16mb_armeb_config.patch
  31. 23 0
      package/boot/apex/patches/140-openwrt_fsg3_armeb_config.patch
  32. 22 0
      package/boot/apex/patches/150-limit_ram_to_64mb.patch
  33. 20 0
      package/boot/apex/patches/160-openwrt_nas100d_armeb_config.patch
  34. 1 1
      package/boot/fconfig/Makefile
  35. 12 2
      package/boot/grub2/Makefile
  36. 8 8
      package/boot/grub2/patches/100-grub_setup_root.patch
  37. 0 26
      package/boot/grub2/patches/100-musl-compat.patch
  38. 13 0
      package/boot/grub2/patches/101-disable-gettext-check-macro-version.patch
  39. 0 14
      package/boot/grub2/patches/210-fix_serial_rtscts.patch
  40. 0 10
      package/boot/kexec-tools/Config.in
  41. 6 5
      package/boot/kexec-tools/Makefile
  42. 0 170
      package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch
  43. 0 51
      package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch
  44. 0 34
      package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch
  45. 0 29
      package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch
  46. 0 29
      package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch
  47. 20 0
      package/boot/kexec-tools/patches/100-format_string_fix.patch
  48. 11 0
      package/boot/kexec-tools/patches/110-fix-vmcore-dmsg-compilation-error.patch
  49. 46 0
      package/boot/kobs-ng/Makefile
  50. 23 0
      package/boot/kobs-ng/patches/001-compile.patch
  51. 45 0
      package/boot/kobs-ng/patches/002-add-init-size-param.patch
  52. 45 0
      package/boot/kobs-ng/patches/003-raw-mode.patch
  53. 27 0
      package/boot/kobs-ng/patches/004-fix-cal_nfc_geometry.patch
  54. 47 0
      package/boot/rbcfg/Makefile
  55. 14 0
      package/boot/rbcfg/src/Makefile
  56. 109 0
      package/boot/rbcfg/src/cyg_crc.h
  57. 172 0
      package/boot/rbcfg/src/cyg_crc32.c
  58. 791 0
      package/boot/rbcfg/src/main.c
  59. 75 0
      package/boot/rbcfg/src/rbcfg.h
  60. 3 1
      package/boot/yamonenv/Makefile
  61. 0 35
      package/kernel/avila-wdt/Makefile
  62. 0 1
      package/kernel/avila-wdt/src/Makefile
  63. 0 231
      package/kernel/avila-wdt/src/avila-wdt.c
  64. 4 4
      package/kernel/kmod-sched-cake/Makefile
  65. 1 1
      package/kernel/linux/modules/can.mk
  66. 1 1
      package/kernel/linux/modules/netfilter.mk
  67. 3 3
      package/kernel/linux/modules/netsupport.mk
  68. 32 0
      package/kernel/linux/modules/nls.mk
  69. 3 3
      package/kernel/mac80211/Makefile
  70. 1 1
      package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
  71. 1 1
      package/kernel/mac80211/files/lib/wifi/mac80211.sh
  72. 3 3
      package/kernel/mac80211/patches/002-change_allconfig.patch
  73. 0 11
      package/kernel/mac80211/patches/004-fix_duplicate_skcipher_backport.patch
  74. 28 0
      package/kernel/mac80211/patches/004-kconfig_backport_fix.patch
  75. 0 22
      package/kernel/mac80211/patches/005-backport_skb_get_hash_perturb.patch
  76. 152 0
      package/kernel/mac80211/patches/005-revert-devcoredump.patch
  77. 20 0
      package/kernel/mac80211/patches/006-revert-ktime-changes.patch
  78. 266 0
      package/kernel/mac80211/patches/007-revert-genetlink-changes.patch
  79. 20 0
      package/kernel/mac80211/patches/008-revert-ndo_stats64-cleanup.patch
  80. 338 0
      package/kernel/mac80211/patches/009-revert-mtu-changes.patch
  81. 43 0
      package/kernel/mac80211/patches/011-backport_strscpy.patch
  82. 47 0
      package/kernel/mac80211/patches/030-rt2x00_options.patch
  83. 9 0
      package/kernel/mac80211/patches/040-brcmutil_option.patch
  84. 2 2
      package/kernel/mac80211/patches/060-no_local_ssb_bcma.patch
  85. 15 0
      package/kernel/mac80211/patches/090-remove-cred.patch
  86. 208 122
      package/kernel/mac80211/patches/100-remove-cryptoapi-dependencies.patch
  87. 1 1
      package/kernel/mac80211/patches/110-mac80211_keep_keys_on_stop_ap.patch
  88. 1 1
      package/kernel/mac80211/patches/130-mac80211-hwsim-hrtimer-clock.patch
  89. 3 3
      package/kernel/mac80211/patches/150-disable_addr_notifier.patch
  90. 1 1
      package/kernel/mac80211/patches/210-ap_scan.patch
  91. 0 953
      package/kernel/mac80211/patches/300-ath9k-Switch-to-using-mac80211-intermediate-software.patch
  92. 0 0
      package/kernel/mac80211/patches/300-ath9k_hw-reset-AHB-WMAC-interface-on-AR91xx.patch
  93. 27 24
      package/kernel/mac80211/patches/315-ath9k_hw-issue-external-reset-for-QCA955x.patch
  94. 0 0
      package/kernel/mac80211/patches/302-ath9k_hw-set-spectral-scan-enable-bit-on-trigger-for.patch
  95. 2 1
      package/kernel/mac80211/patches/347-ath9k-don-t-run-periodic-and-nf-calibation-at-the-sa.patch
  96. 1 1
      package/kernel/mac80211/patches/301-ath9k-force-rx_clear-when-disabling-rx.patch
  97. 7 7
      package/kernel/mac80211/patches/302-ath9k-limit-retries-for-powersave-response-frames.patch
  98. 2 2
      package/kernel/mac80211/patches/303-Revert-ath9k-interpret-requested-txpower-in-EIRP-dom.patch
  99. 11 11
      package/kernel/mac80211/patches/304-mac80211-add-hdrlen-to-ieee80211_tx_data.patch
  100. 0 0
      package/kernel/mac80211/patches/305-mac80211-add-NEED_ALIGNED4_SKBS-hw-flag.patch

+ 1 - 1
Makefile

@@ -14,7 +14,7 @@ export TOPDIR LC_ALL LANG TZ
 
 empty:=
 space:= $(empty) $(empty)
-$(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the libreCMC directory must not include any spaces))
+$(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the LEDE directory must not include any spaces))
 
 world:
 

+ 12 - 2
config/Config-build.in

@@ -9,7 +9,7 @@ menu "Global build settings"
 
 	config ALL_NONSHARED
 		bool "Select all target specific packages by default"
-		default ALL
+		default ALL || BUILDBOT
 
 	config ALL_KMODS
 		bool "Select all kernel module packages by default"
@@ -19,6 +19,16 @@ menu "Global build settings"
 		bool "Select all userspace packages by default"
 		default n
 
+	config BUILDBOT
+		bool "Set build defaults for automatic builds (e.g. via buildbot)"
+		default n
+		help
+		  This option changes several defaults to be more suitable for
+		  automatic builds. This includes the following changes:
+		  - Deleting build directories after compiling (to save space)
+		  - Enabling per-device rootfs support
+		  ...
+
 	config SIGNED_PACKAGES
 		bool "Cryptographically signed package lists"
 		default y
@@ -61,7 +71,7 @@ menu "Global build settings"
 		bool
 		prompt "Collect kernel debug information"
 		select KERNEL_DEBUG_INFO
-		default n
+		default BUILDBOT
 		help
 		  This collects debugging symbols from the kernel and all compiled modules.
 		  Useful for release builds, so that kernel issues can be debugged offline

+ 1 - 1
config/Config-devel.in

@@ -59,7 +59,7 @@ menuconfig DEVEL
 		bool "Use ccache" if DEVEL
 		default n
 		help
-		  Compiler cache; see http://ccache.samba.org/.
+		  Compiler cache; see https://ccache.samba.org/
 
 	config EXTERNAL_KERNEL_TREE
 		string "Use external kernel tree" if DEVEL

+ 0 - 1
config/Config-images.in

@@ -201,7 +201,6 @@ menu "Target Images"
 		int "Serial port baud rate"
 		depends on GRUB_IMAGES
 		default 38400 if TARGET_x86_generic
-		default 38400 if TARGET_x86_geode
 		default 115200
 
 	config GRUB_BOOTOPTS

+ 1 - 1
config/Config-kernel.in

@@ -26,7 +26,7 @@ config KERNEL_PRINTK
 
 config KERNEL_CRASHLOG
 	bool "Crash logging"
-	depends on !(arm || powerpc || sparc || TARGET_uml)
+	depends on !(arm || powerpc || sparc || TARGET_uml || i386 || x86_64)
 	default y
 
 config KERNEL_SWAP

+ 2 - 2
include/autotools.mk

@@ -85,11 +85,11 @@ endef
 
 define gettext_version_target
 	(cd $(PKG_BUILD_DIR) && \
-		GETTEXT_VERSION=$(shell $(STAGING_DIR)/host/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -ne '1s/.*\([0-9]\.[0-9]\{2\}\.[0-9]\).*/\1/p' ) && \
+		GETTEXT_VERSION=$(shell $(STAGING_DIR_HOSTPKG)/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -ne '1s/.*\([0-9]\.[0-9]\{2\}\.[0-9]\).*/\1/p' ) && \
 		$(STAGING_DIR_HOST)/bin/sed \
 			-i $(PKG_BUILD_DIR)/configure.ac \
 			-e "s/AM_GNU_GETTEXT_VERSION(.*)/AM_GNU_GETTEXT_VERSION(\[$$$$GETTEXT_VERSION\])/g" && \
-		$(STAGING_DIR)/host/bin/autopoint --force \
+		$(STAGING_DIR_HOSTPKG)/bin/autopoint --force \
 	);
 endef
 

+ 4 - 0
include/cmake.mk

@@ -107,3 +107,7 @@ define Host/Configure/Default
 		$(HOST_CMAKE_SOURCE_DIR) \
 	)
 endef
+
+MAKE_FLAGS += \
+	CMAKE_COMMAND='$$(if $$(CMAKE_DISABLE_$$@),:,$(STAGING_DIR_HOST)/bin/cmake)' \
+	CMAKE_DISABLE_cmake_check_build_system=1

+ 0 - 3
include/download.mk

@@ -94,13 +94,10 @@ endif
 
 C_md5_deprecated = Use of $(2) is deprecated, switch to $(3)
 
-# Skip MD5SUM check in feeds until OpenWrt is updated
-ifneq ($(filter $(foreach dir,package tools toolchain, $(TOPDIR)/$(dir)/%),$(CURDIR)),)
 check_md5 = \
   $(if $(filter-out x,$(1)), \
     $(call check_warn,md5_deprecated,$(1),$(2),$(3)) \
   )
-endif
 
 hash_var = $(if $(filter-out x,$(1)),MD5SUM,HASH)
 endif

+ 1 - 1
include/feeds.mk

@@ -10,7 +10,7 @@
 
 FEEDS_INSTALLED:=$(notdir $(wildcard $(TOPDIR)/package/feeds/*))
 FEEDS_AVAILABLE:=$(sort $(FEEDS_INSTALLED) $(shell $(SCRIPT_DIR)/feeds list -n))
-FEEDS_ENABLED:=$(foreach feed,$(FEEDS_INSTALLED),$(if $(CONFIG_FEED_$(feed)),$(feed)))
+FEEDS_ENABLED:=$(foreach feed,$(FEEDS_AVAILABLE),$(if $(CONFIG_FEED_$(feed)),$(feed)))
 FEEDS_DISABLED:=$(filter-out $(FEEDS_ENABLED),$(FEEDS_AVAILABLE))
 
 PACKAGE_SUBDIRS=$(PACKAGE_DIR)

+ 8 - 1
include/host-build.mk

@@ -67,6 +67,12 @@ HOST_CONFIGURE_ARGS = \
 	--localstatedir=$(HOST_BUILD_PREFIX)/var \
 	--sbindir=$(HOST_BUILD_PREFIX)/bin
 
+HOST_MAKE_VARS = \
+	CFLAGS="$(HOST_CFLAGS)" \
+	CPPFLAGS="$(HOST_CPPFLAGS)" \
+	CXXFLAGS="$(HOST_CXXFLAGS)" \
+	LDFLAGS="$(HOST_LDFLAGS)"
+
 HOST_MAKE_FLAGS =
 
 HOST_CONFIGURE_CMD = $(BASH) ./configure
@@ -89,7 +95,8 @@ define Host/Configure
 endef
 
 define Host/Compile/Default
-	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
+	+$(HOST_MAKE_VARS) \
+	$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
 		$(HOST_MAKE_FLAGS) \
 		$(1)
 endef

+ 1 - 1
include/image-commands.mk

@@ -59,7 +59,7 @@ define Build/fit
 		-D $(DEVICE_NAME) -o $@.its -k $@ \
 		$(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \
 		-a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
-		-A $(ARCH) -v $(LINUX_VERSION)
+		-A $(LINUX_KARCH) -v $(LINUX_VERSION)
 	PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
 	@mv $@.new $@
 endef

+ 14 - 2
include/image.mk

@@ -143,10 +143,17 @@ endef
 define Image/BuildKernel/MkFIT
 	$(TOPDIR)/scripts/mkits.sh \
 		-D $(1) -o $(KDIR)/fit-$(1).its -k $(2) $(if $(3),-d $(3)) -C $(4) -a $(5) -e $(6) \
-		-A $(ARCH) -v $(LINUX_VERSION)
+		-A $(LINUX_KARCH) -v $(LINUX_VERSION)
 	PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(1).its $(KDIR)/fit-$(1)$(7).itb
 endef
 
+ifdef CONFIG_TARGET_IMAGES_GZIP
+  define Image/Gzip
+	rm -f $(1).gz
+	gzip -9n $(1)
+  endef
+endif
+
 # $(1) source dts file
 # $(2) target dtb file
 # $(3) extra CPP flags
@@ -445,7 +452,8 @@ define Device/Build/kernel
 endef
 
 define Device/Build/image
-  $$(_TARGET): $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
+  GZ_SUFFIX := $(if $(filter %dtb %gz,$(2)),,$(if $(and $(findstring ext4,$(1)),$(CONFIG_TARGET_IMAGES_GZIP)),.gz))
+  $$(_TARGET): $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))$$(GZ_SUFFIX)
   $(eval $(call Device/Export,$(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)),$(1)))
   ROOTFS/$(1)/$(3) := \
 	$(KDIR)/root.$(1)$$(strip \
@@ -462,6 +470,10 @@ define Device/Build/image
 	$$(call concat_cmd,$(if $(IMAGE/$(2)/$(1)),$(IMAGE/$(2)/$(1)),$(IMAGE/$(2))))
 
   .IGNORE: $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
+
+  $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)).gz: $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
+	gzip -c -9n $$^ > $$@
+
   $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
 	cp $$^ $$@
 

+ 1 - 1
include/kernel-build.mk

@@ -60,7 +60,7 @@ define Download/git-kernel
   PROTO:=git
   VERSION:=$(CONFIG_KERNEL_GIT_BRANCH)
   FILE:=$(LINUX_SOURCE)
-  SUBDIR:=linux-$(KERNEL_PATCHVER)
+  SUBDIR:=linux-$(LINUX_VERSION)
   OPTS:=$(KERNEL_GIT_OPTS)
 endef
 

+ 3 - 3
include/kernel-version.mk

@@ -3,10 +3,10 @@
 LINUX_RELEASE?=1
 
 LINUX_VERSION-3.18 = .43
-LINUX_VERSION-4.4 = .40
+LINUX_VERSION-4.4 = .52
 
-LINUX_KERNEL_HASH-3.18.43 = 648a61fb3b1d09a14f50a9ced13977302d57b32e2826877950071dc70541f918
-LINUX_KERNEL_HASH-4.4.40 = a3c006893966ec9bee23edb41eebbe2cf0481efe205bf037ee0cc43ce427fc22
+LINUX_KERNEL_HASH-3.18.43 = 
+LINUX_KERNEL_HASH-4.4.52 = 0f1faafdae47da5f29e740ff655f91c2eb13c8cdfc4d039d903176bd56c2ecbb
 
 ifdef KERNEL_PATCHVER
   LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER)))

+ 2 - 0
include/package-ipkg.mk

@@ -209,11 +209,13 @@ $(_endef)
 		( \
 			echo "#!/bin/sh"; \
 			echo "[ \"\$$$${IPKG_NO_SCRIPT}\" = \"1\" ] && exit 0"; \
+			echo "[ -x "\$$$${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0"; \
 			echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
 			echo "default_postinst \$$$$0 \$$$$@"; \
 		) > postinst; \
 		( \
 			echo "#!/bin/sh"; \
+			echo "[ -x "\$$$${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0"; \
 			echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
 			echo "default_prerm \$$$$0 \$$$$@"; \
 		) > prerm; \

+ 9 - 1
include/rootfs.mk

@@ -47,6 +47,14 @@ opkg = \
 
 TARGET_DIR_ORIG := $(TARGET_ROOTFS_DIR)/root.orig-$(BOARD)
 
+ifdef CONFIG_CLEAN_IPKG
+  define clean_ipkg
+	-find $(1)/usr/lib/opkg -type f -and -not -name '*.control' | $(XARGS) rm -rf
+	-sed -i -ne '/^Require-User: /p' $(1)/usr/lib/opkg/info/*.control
+	-find $(1)/usr/lib/opkg -empty | $(XARGS) rm -rf
+  endef
+endif
+
 define prepare_rootfs
 	@if [ -d $(TOPDIR)/files ]; then \
 		$(call file_copy,$(TOPDIR)/files/.,$(1)); \
@@ -75,6 +83,6 @@ define prepare_rootfs
 	rm -f $(1)/usr/lib/opkg/lists/*
 	rm -f $(1)/usr/lib/opkg/info/*.postinst*
 	rm -f $(1)/usr/lib/opkg/info/*.prerm*
-	$(if $(CONFIG_CLEAN_IPKG),rm -rf $(1)/usr/lib/opkg)
+	$(call clean_ipkg,$(1))
 	$(call mklibs,$(1))
 endef

+ 6 - 5
include/target.mk

@@ -13,7 +13,7 @@ __target_inc=1
 DEVICE_TYPE?=router
 
 # Default packages - the really basic set
-DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch
+DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd
 # For nas targets
 DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm
 # For router targets
@@ -164,17 +164,15 @@ ifeq ($(DUMP),1)
     endif
     CPU_CFLAGS += -mno-branch-likely
     CPU_CFLAGS_mips32 = -mips32 -mtune=mips32
-    CPU_CFLAGS_mips32r2 = -mips32r2 -mtune=mips32r2
     CPU_CFLAGS_mips64 = -mips64 -mtune=mips64 -mabi=64
     CPU_CFLAGS_24kc = -mips32r2 -mtune=24kc
     CPU_CFLAGS_74kc = -mips32r2 -mtune=74kc
     CPU_CFLAGS_octeon = -march=octeon -mabi=64
   endif
   ifeq ($(ARCH),i386)
-    CPU_TYPE ?= i486
-    CPU_CFLAGS_i486 = -march=i486
+    CPU_TYPE ?= pentium
+    CPU_CFLAGS_pentium = -march=pentium-mmx
     CPU_CFLAGS_pentium4 = -march=pentium4
-    CPU_CFLAGS_geode = -march=geode -mmmx -m3dnow
   endif
   ifneq ($(findstring arm,$(ARCH)),)
     CPU_TYPE ?= xscale
@@ -259,6 +257,9 @@ ifeq ($(DUMP),1)
     ifneq ($(CONFIG_VIRTIO),)
       FEATURES += virtio
     endif
+    ifneq ($(CONFIG_CPU_MIPS32_R2),)
+      FEATURES += mips16
+    endif
     FEATURES += $(foreach v,6 7,$(if $(CONFIG_CPU_V$(v)),arm_v$(v)))
 
     # remove duplicates

+ 3 - 2
package/base-files/Makefile

@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
 include $(INCLUDE_DIR)/version.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=171
+PKG_RELEASE:=172
 PKG_FLAGS:=nonshared
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
@@ -31,7 +31,7 @@ define Package/base-files
   SECTION:=base
   CATEGORY:=Base system
   DEPENDS:=+netifd +libc +procd +jsonfilter +SIGNED_PACKAGES:usign +SIGNED_PACKAGES:lede-keyring +fstools +fwtool
-  TITLE:=Base filesystem for Lede
+  TITLE:=Base filesystem for libreCMC
   URL:=http://openwrt.org/
   VERSION:=$(PKG_RELEASE)-$(REVISION)
 endef
@@ -57,6 +57,7 @@ define Package/base-files/conffiles
 /etc/sysctl.d/local.conf
 /etc/sysctl.d/
 /etc/iproute2/rt_tables
+/etc/iproute2/rt_protos
 $(call $(TARGET)/conffiles)
 endef
 

+ 1 - 1
package/base-files/files/etc/init.d/system

@@ -7,7 +7,7 @@ USE_PROCD=1
 validate_system_section()
 {
 	uci_validate_section system system "${1}" \
-		'hostname:string:libreCMC' \
+		'hostname:string:lede' \
 		'conloglevel:uinteger' \
 		'buffersize:uinteger' \
 		'timezone:string:UTC' \

+ 18 - 0
package/base-files/files/etc/iproute2/rt_protos

@@ -0,0 +1,18 @@
+#
+# Reserved protocols.
+#
+0	unspec
+1	redirect
+2	kernel
+3	boot
+4	static
+8	gated
+9	ra
+10	mrt
+11	zebra
+12	bird
+13	dnrouted
+14	xorp
+15	ntk
+16	dhcp
+42	babel

+ 1 - 0
package/base-files/files/etc/openwrt_release

@@ -3,5 +3,6 @@ DISTRIB_RELEASE='%V'
 DISTRIB_REVISION='%R'
 DISTRIB_CODENAME='%n'
 DISTRIB_TARGET='%S'
+DISTRIB_ARCH='%A'
 DISTRIB_DESCRIPTION='%D %N %V %C'
 DISTRIB_TAINTS='%t'

+ 1 - 1
package/base-files/files/etc/uci-defaults/13_fix_group_user

@@ -2,7 +2,7 @@
 
 . /lib/functions.sh
 
-for file in `grep Require-User /usr/lib/opkg/info/*.control | cut -d: -f1`; do
+for file in `grep -sl Require-User /usr/lib/opkg/info/*.control`; do
 	file="${file##*/}"
 	file="${file%.control}"
 	add_group_and_user "${file}"

+ 1 - 1
package/base-files/files/lib/preinit/10_sysinfo

@@ -3,7 +3,7 @@ do_sysinfo_generic() {
 	mkdir -p /tmp/sysinfo
 	[ -e /tmp/sysinfo/board_name ] || \
 		echo "$(strings /proc/device-tree/compatible | head -1)" > /tmp/sysinfo/board_name
-	[ -n /tmp/sysinfo/model -a -e /proc/device-tree/model ] && \
+	[ ! -e /tmp/sysinfo/model -a -e /proc/device-tree/model ] && \
 		echo "$(cat /proc/device-tree/model)" > /tmp/sysinfo/model
 }
 

+ 9 - 3
package/base-files/files/sbin/wifi

@@ -6,8 +6,8 @@
 
 usage() {
 	cat <<EOF
-Usage: $0 [down|detect|reload|status]
-enables (default), disables or detects a wifi configuration.
+Usage: $0 [config|down|reload|status]
+enables (default), disables or configures devices not yet configured.
 EOF
 	exit 1
 }
@@ -145,6 +145,12 @@ wifi_reload() {
 	wifi_reload_legacy
 }
 
+wifi_detect_notice() {
+	>&2 echo "WARNING: Wifi detect is deprecated. Use wifi config instead"
+	>&2 echo "For more information, see commit 5f8f8a366136a07df661e31decce2458357c167a"
+	exit 1
+}
+
 wifi_config() {
 	[ ! -f /etc/config/wireless ] && touch /etc/config/wireless
 
@@ -229,7 +235,7 @@ scan_wifi
 
 case "$1" in
 	down) wifi_updown "disable" "$2";;
-	detect) ;;
+	detect) wifi_detect_notice ;;
 	config) wifi_config ;;
 	status) ubus_wifi_cmd "status" "$2";;
 	reload) wifi_reload "$2";;

+ 1 - 0
package/base-files/files/usr/lib/os-release

@@ -9,6 +9,7 @@ BUG_URL="%b"
 SUPPORT_URL="%s"
 BUILD_ID="%R"
 LEDE_BOARD="%S"
+LEDE_ARCH="%A"
 LEDE_TAINTS="%t"
 LEDE_DEVICE_MANUFACTURER="%M"
 LEDE_DEVICE_MANUFACTURER_URL="%m"

+ 3 - 3
package/base-files/image-config.in

@@ -92,7 +92,7 @@ config TARGET_PREINIT_NETMASK
 config TARGET_PREINIT_BROADCAST
 	string
 	prompt "Broadcast address for preinit network messages" if PREINITOPT
-	default "192.168.10.255"
+	default "192.168.1.255"
 	help
 		Broadcast address to which to send preinit network messages, as
 		as failsafe messages
@@ -190,7 +190,7 @@ if VERSIONOPT
 	config VERSION_REPO
 		string
 		prompt "Release repository"
-		default "http://downloads.lede-project.org/snapshots"
+		default "http://downloads.lede-project.org/releases/17.01-SNAPSHOT"
 		help
 			This is the repository address embedded in the image, it defaults
 			to the trunk snapshot repo; the url may contain the following placeholders:
@@ -286,7 +286,7 @@ menuconfig PER_FEED_REPO
 
 	config PER_FEED_REPO_ADD_COMMENTED
 		bool "Comment out not enabled feeds"
-		default y
+		default !BUILDBOT
 		depends on PER_FEED_REPO && PER_FEED_REPO_ADD_DISABLED
 		help
 		  Add not enabled feeds as commented out source lines to opkg.conf.

+ 62 - 0
package/boot/apex/Makefile

@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=apex
+PKG_VERSION:=1.6.9
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.openwrt.org/sources/
+PKG_HASH:=1d2bc04c2c6bb3d2d6c1916b6dc559cda2b1ecb045d7801fd49af6af4234abeb
+PKG_TARGETS:=bin
+
+include $(INCLUDE_DIR)/package.mk
+
+export GCC_HONOUR_COPTS=s
+
+define Package/apex
+  SECTION:=boot
+  CATEGORY:=Boot Loaders
+  DEPENDS:=@TARGET_ixp4xx
+  DEFAULT:=y
+  TITLE:=Boot loader for NSLU2, FSG3, NAS100D and others
+  URL:=http://wiki.buici.com/wiki/Apex_Bootloader
+endef
+
+define build_apex
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		ARCH=arm \
+		$(1)_config
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		$(TARGET_CONFIGURE_OPTS) \
+		KBUILD_HAVE_NLS=no \
+		ARCH=arm \
+		clean all
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/apex.bin $(PKG_BUILD_DIR)/out/apex-$(2).bin
+endef
+
+define Build/Compile
+	$(INSTALL_DIR) $(PKG_BUILD_DIR)/out
+	$(call build_apex,slugos-nslu2-armeb,nslu2-armeb)
+	$(call build_apex,slugos-nslu2-16mb-armeb,nslu2-16mb-armeb)
+	$(call build_apex,slugos-fsg3-armeb,fsg3-armeb)
+	$(call build_apex,slugos-nas100d-armeb,nas100d-armeb)
+endef
+
+define Package/apex/install
+	$(INSTALL_DIR) $(STAGING_DIR)/apex
+	$(CP) $(PKG_BUILD_DIR)/out/*.bin $(1)/
+endef
+
+define Build/InstallDev
+	$(CP) $(PKG_BUILD_DIR)/out/*.bin $(KERNEL_BUILD_DIR)
+endef
+
+$(eval $(call BuildPackage,apex))

+ 20 - 0
package/boot/apex/patches/001-compile_fix.patch

@@ -0,0 +1,20 @@
+--- a/Makefile
++++ b/Makefile
+@@ -444,7 +444,7 @@ ifeq ($(config-targets),1)
+ include $(srctree)/src/arch-$(SRCARCH)/Makefile
+ export KBUILD_DEFCONFIG
+ 
+-config %config: scripts_basic outputmakefile FORCE
++%config: scripts_basic outputmakefile FORCE
+ 	$(Q)mkdir -p include/linux include/config
+ 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
+ 
+@@ -1585,7 +1585,7 @@ endif
+ 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ 
+ # Modules
+-/ %/: prepare scripts FORCE
++%/: prepare scripts FORCE
+ 	$(cmd_crmodverdir)
+ 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
+ 	$(build)=$(build-dir)

+ 23 - 0
package/boot/apex/patches/100-openwrt_nslu2_armeb_config.patch

@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-nslu2-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NSLU2 (bigendian)"
++CONFIG_TARGET_DESCRIPTION="OpenWrt NSLU2 (8MiB Flash)"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -163,9 +163,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y

+ 23 - 0
package/boot/apex/patches/120-openwrt_nslu2_16mb_armeb_config.patch

@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NSLU2/BE (16MiB Flash)"
++CONFIG_TARGET_DESCRIPTION="OpenWrt NSLU2 (16MiB Flash)"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -163,9 +163,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock4 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y

+ 23 - 0
package/boot/apex/patches/140-openwrt_fsg3_armeb_config.patch

@@ -0,0 +1,23 @@
+--- a/src/mach-ixp42x/slugos-fsg3-armeb_config
++++ b/src/mach-ixp42x/slugos-fsg3-armeb_config
+@@ -17,7 +17,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS FSG3/BE"
++CONFIG_TARGET_DESCRIPTION="OpenWrt FSG3"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+@@ -148,9 +148,9 @@ CONFIG_ENV_REGION_KERNEL_ALT="fis://kern
+ #    Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/sda1 rootdelay=10 console=ttyS0,115200"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/sda1 rootdelay=10 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ CONFIG_ENV_DEFAULT_CMDLINE_ALT_P=y
+-CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/sda2 rootdelay=10 console=ttyS0,115200"
++CONFIG_ENV_DEFAULT_CMDLINE_ALT="root=/dev/mtdblock2 rootfstype=squashfs console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ # CONFIG_ENV_DEFAULT_STARTUP_ALT_P is not set
+ CONFIG_USES_NOR_BOOTFLASH=y

+ 22 - 0
package/boot/apex/patches/150-limit_ram_to_64mb.patch

@@ -0,0 +1,22 @@
+--- a/src/mach-ixp42x/slugos-nslu2-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-armeb_config
+@@ -137,7 +137,7 @@ CONFIG_AUTOBOOT_DELAY=10
+ CONFIG_ENV_STARTUP_KERNEL_COPY=y
+ # CONFIG_ENV_REGION_KERNEL_SWAP is not set
+ CONFIG_ENV_STARTUP_PREFIX_P=y
+-CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+256m"
++CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+64m"
+ 
+ #
+ #    Regions
+--- a/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
++++ b/src/mach-ixp42x/slugos-nslu2-16mb-armeb_config
+@@ -137,7 +137,7 @@ CONFIG_AUTOBOOT_DELAY=10
+ CONFIG_ENV_STARTUP_KERNEL_COPY=y
+ # CONFIG_ENV_REGION_KERNEL_SWAP is not set
+ CONFIG_ENV_STARTUP_PREFIX_P=y
+-CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+256m"
++CONFIG_ENV_STARTUP_PREFIX="sdram-init; memscan -u 0+64m"
+ 
+ #
+ #    Regions

+ 20 - 0
package/boot/apex/patches/160-openwrt_nas100d_armeb_config.patch

@@ -0,0 +1,20 @@
+--- a/src/mach-ixp42x/slugos-nas100d-armeb_config
++++ b/src/mach-ixp42x/slugos-nas100d-armeb_config
+@@ -19,7 +19,7 @@ CONFIG_EXPERIMENTAL=y
+ #
+ # General Setup
+ #
+-CONFIG_TARGET_DESCRIPTION="SlugOS NAS100D/BE"
++CONFIG_TARGET_DESCRIPTION="OpenWrt NAS100D"
+ CONFIG_CROSS_COMPILE=""
+ CONFIG_AEABI=y
+ # CONFIG_DRIVER_LONG_LONG_SIZE is not set
+@@ -158,7 +158,7 @@ CONFIG_ENV_REGION_KERNEL="fis://kernel"
+ # Overrides
+ #
+ CONFIG_ENV_DEFAULT_CMDLINE_OVERRIDE=y
+-CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock2 rootfstype=jffs2 console=ttyS0,115200 init=/linuxrc"
++CONFIG_ENV_DEFAULT_CMDLINE="root=/dev/mtdblock2 rootfstype=squashfs,jffs2 console=ttyS0,115200 init=/etc/preinit noinitrd"
+ # CONFIG_ENV_DEFAULT_STARTUP_OVERRIDE is not set
+ CONFIG_USES_NOR_BOOTFLASH=y
+ CONFIG_RELOCATE_SIMPLE=y

+ 1 - 1
package/boot/fconfig/Makefile

@@ -13,7 +13,7 @@ PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://andrzejekiert.ovh.org/software/fconfig/
-PKG_MD5SUM:=dac355e9f2a0f48c414c52e2034b6346
+PKG_HASH:=4ff0e8f07e35e46b705c0dbe9d9544ede01ea092a69e3f7db03e55a3f2bb8eb7
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
 

+ 12 - 2
package/boot/grub2/Makefile

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=grub
-PKG_VERSION:=2.02~beta2
+PKG_VERSION:=2.02~rc1
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
@@ -17,13 +17,16 @@ PKG_SOURCE_URL:=http://alpha.gnu.org/gnu/grub \
 	http://gnualpha.uib.no/grub/ \
 	http://mirrors.fe.up.pt/pub/gnu-alpha/grub/ \
 	http://www.nic.funet.fi/pub/gnu/alpha/gnu/grub/
-PKG_MD5SUM:=be62932eade308a364ea4bbc91295930
+PKG_HASH:=445239e9b96d1143c194c1d37851cf4196b83701c60172e49665e9d453d80278
 
+PKG_FIXUP:=autoreconf
 HOST_BUILD_PARALLEL:=1
 PKG_BUILD_DEPENDS:=grub2/host
 
 PKG_SSP:=0
 
+PKG_FLAGS:=nonshared
+
 include $(INCLUDE_DIR)/host-build.mk
 include $(INCLUDE_DIR)/package.mk
 
@@ -50,6 +53,9 @@ endef
 
 HOST_BUILD_PREFIX := $(STAGING_DIR_HOST)
 
+CONFIGURE_VARS += \
+	grub_build_mkfont_excuse="don't want fonts"
+
 CONFIGURE_ARGS += \
 	--target=$(REAL_GNU_TARGET_NAME) \
 	--disable-werror \
@@ -58,7 +64,11 @@ CONFIGURE_ARGS += \
 	--disable-libzfs \
 	--disable-grub-mkfont
 
+HOST_CONFIGURE_VARS += \
+	grub_build_mkfont_excuse="don't want fonts"
+
 HOST_CONFIGURE_ARGS += \
+	--disable-grub-mkfont \
 	--target=$(REAL_GNU_TARGET_NAME) \
 	--sbindir="$(STAGING_DIR_HOST)/bin" \
 	--disable-werror \

+ 8 - 8
package/boot/grub2/patches/100-grub_setup_root.patch

@@ -17,7 +17,7 @@
    int  force;
    int  fs_probe;
    int allow_floppy;
-@@ -178,6 +181,13 @@ argp_parser (int key, char *arg, struct 
+@@ -178,6 +181,13 @@ argp_parser (int key, char *arg, struct argp_state *state)
          arguments->dev_map = xstrdup (arg);
          break;
  
@@ -42,7 +42,7 @@
  
 --- a/util/setup.c
 +++ b/util/setup.c
-@@ -247,13 +247,12 @@ identify_partmap (grub_disk_t disk __att
+@@ -247,13 +247,12 @@ identify_partmap (grub_disk_t disk __attribute__ ((unused)),
  void
  SETUP (const char *dir,
         const char *boot_file, const char *core_file,
@@ -69,7 +69,7 @@
      char **root_devices = grub_guess_root_devices (dir);
      char **cur;
      int found = 0;
-@@ -317,6 +319,8 @@ SETUP (const char *dir,
+@@ -320,6 +322,8 @@ SETUP (const char *dir,
  	char *drive;
  	grub_device_t try_dev;
  
@@ -80,7 +80,7 @@
  	  continue;
 --- a/include/grub/util/install.h
 +++ b/include/grub/util/install.h
-@@ -182,13 +182,13 @@ grub_install_get_image_target (const cha
+@@ -184,13 +184,13 @@ grub_install_get_image_target (const char *arg);
  void
  grub_util_bios_setup (const char *dir,
  		      const char *boot_file, const char *core_file,
@@ -98,7 +98,7 @@
  
 --- a/util/grub-install.c
 +++ b/util/grub-install.c
-@@ -1660,7 +1660,7 @@ main (int argc, char *argv[])
+@@ -1673,7 +1673,7 @@ main (int argc, char *argv[])
  	/*  Now perform the installation.  */
  	if (install_bootsector)
  	  grub_util_bios_setup (platdir, "boot.img", "core.img",
@@ -107,12 +107,12 @@
  				fs_probe, allow_floppy, add_rs_codes);
  	break;
        }
-@@ -1686,7 +1686,7 @@ main (int argc, char *argv[])
+@@ -1699,7 +1699,7 @@ main (int argc, char *argv[])
  	/*  Now perform the installation.  */
  	if (install_bootsector)
  	  grub_util_sparc_setup (platdir, "boot.img", "core.img",
--				 install_device, force,
-+				 NULL, install_device, force,
+-				 install_drive, force,
++				 NULL, install_drive, force,
  				 fs_probe, allow_floppy,
  				 0 /* unused */ );
  	break;

+ 0 - 26
package/boot/grub2/patches/100-musl-compat.patch

@@ -1,26 +0,0 @@
---- a/grub-core/osdep/unix/hostdisk.c
-+++ b/grub-core/osdep/unix/hostdisk.c
-@@ -48,11 +48,10 @@
- #ifdef __linux__
- # include <sys/ioctl.h>         /* ioctl */
- # include <sys/mount.h>
--# if !defined(__GLIBC__) || \
--        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))
-+# if defined(__UCLIBC__)
- /* Maybe libc doesn't have large file support.  */
- #  include <linux/unistd.h>     /* _llseek */
--# endif /* (GLIBC < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR < 1)) */
-+# endif /* __UCLIBC__ */
- #endif /* __linux__ */
- 
- grub_uint64_t
-@@ -79,8 +78,7 @@ grub_util_get_fd_size (grub_util_fd_t fd
-   return st.st_size;
- }
- 
--#if defined(__linux__) && (!defined(__GLIBC__) || \
--        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
-+#if defined(__linux__) && defined(__UCLIBC__)
-   /* Maybe libc doesn't have large file support.  */
- int
- grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)

+ 13 - 0
package/boot/grub2/patches/101-disable-gettext-check-macro-version.patch

@@ -0,0 +1,13 @@
+diff --git a/po/Makefile.in.in b/po/Makefile.in.in
+index 3619458..060e0db 100644
+--- a/po/Makefile.in.in
++++ b/po/Makefile.in.in
+@@ -97,7 +97,7 @@ CATALOGS = @CATALOGS@
+ 	mv t-$@ $@
+ 
+ 
+-all: check-macro-version all-@USE_NLS@
++all: all-@USE_NLS@
+ 
+ all-yes: stamp-po
+ all-no:

+ 0 - 14
package/boot/grub2/patches/210-fix_serial_rtscts.patch

@@ -1,14 +0,0 @@
---- a/grub-core/term/serial.c
-+++ b/grub-core/term/serial.c
-@@ -241,9 +241,9 @@ grub_cmd_serial (grub_extcmd_context_t c
- 
-   if (state[OPTION_RTSCTS].set)
-     {
--      if (grub_strcmp (state[OPTION_PARITY].arg, "on") == 0)
-+      if (grub_strcmp (state[OPTION_RTSCTS].arg, "on") == 0)
- 	config.rtscts = 1;
--      if (grub_strcmp (state[OPTION_PARITY].arg, "off") == 0)
-+      else if (grub_strcmp (state[OPTION_RTSCTS].arg, "off") == 0)
- 	config.rtscts = 0;
-       else
- 	return grub_error (GRUB_ERR_BAD_ARGUMENT,

+ 0 - 10
package/boot/kexec-tools/Config.in

@@ -1,16 +1,6 @@
 menu "Configuration"
 	depends on PACKAGE_kexec-tools
 
-config KEXEC_TOOLS_TARGET_NAME
-	string
-	prompt "Target name for kexec kernel"
-	default EXTRA_TARGET_ARCH_NAME	if powerpc64
-	default ARCH
-	help
-	  Defines the target type of the kernels that kexec deals
-	  with. This should be the target specification of
-	  the kernel you're booting.
-
 config KEXEC_TOOLS_kdump
 	bool
 	prompt "kdump support"

+ 6 - 5
package/boot/kexec-tools/Makefile

@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=kexec-tools
-PKG_VERSION:=2.0.9
+PKG_VERSION:=2.0.14-rc1
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
-PKG_MD5SUM:=6681319934e22e74c532bd392ccb1bbb
+PKG_HASH:=3fc505ff8d8a2d24c68aac5e6b4783997d5a086966ff3de8b05a0ceb27e5e23b
 
 PKG_FIXUP:=autoreconf
 
@@ -24,7 +24,7 @@ include $(INCLUDE_DIR)/package.mk
 define Package/kexec-tools
   SECTION:=utils
   CATEGORY:=Utilities
-  DEPENDS:=@KERNEL_KEXEC @armeb||@arm||@i386||@powerpc64||@mipsel||@mips +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma
+  DEPENDS:=@armeb||@arm||@i386||@x86_64||@powerpc64||@mipsel||@mips +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma
   TITLE:=Kernel boots kernel
   URL:=http://kernel.org/pub/linux/kernel/people/horms/kexec-tools/
   MAINTAINER:=Florian Fainelli <florian@openwrt.org>
@@ -40,7 +40,7 @@ define Package/kexec-tools/config
 	source "$(SOURCE)/Config.in"
 endef
 
-KEXEC_TARGET_NAME:=$(call qstrip,$(CONFIG_KEXEC_TOOLS_TARGET_NAME))-linux-$(TARGET_SUFFIX)
+KEXEC_TARGET_NAME:=$(ARCH)-linux-$(TARGET_SUFFIX)
 
 CONFIGURE_ARGS = \
 		--target=$(KEXEC_TARGET_NAME) \
@@ -55,7 +55,8 @@ CONFIGURE_ARGS = \
 		--libexecdir=/usr/lib \
 		--sysconfdir=/etc \
 		$(if $(CONFIG_KEXEC_ZLIB),--with,--without)-zlib \
-		$(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma
+		$(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma \
+		TARGET_LD="$(TARGET_CROSS)ld"
 
 TARGET_CFLAGS += -ffunction-sections -fdata-sections
 TARGET_LDFLAGS += -Wl,--gc-sections

+ 0 - 170
package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch

@@ -1,171 +0,0 @@
-From d606837b56d46eb7f815b5d85f07fcc3f1555d00 Mon Sep 17 00:00:00 2001
-From: Yousong Zhou <yszhou4tech@gmail.com>
-Date: Sun, 1 Feb 2015 00:10:07 +0800
-Subject: [PATCH 1/5] Fix zlib/lzma decompression.
-
-Let {zlib,lzma}_decompress_file() return NULL if anything wrong happened
-to allow the other method to have a chance to run.
-
-Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-Signed-off-by: Simon Horman <horms@verge.net.au>
----
- kexec/lzma.c |   33 ++++++++++++++++++++++-----------
- kexec/zlib.c |   57 +++++++++++++++++++++++++++++++++++----------------------
- 2 files changed, 57 insertions(+), 33 deletions(-)
-
-diff --git a/kexec/lzma.c b/kexec/lzma.c
-index 939aeb3..5bfccb7 100644
---- a/kexec/lzma.c
-+++ b/kexec/lzma.c
-@@ -162,13 +162,16 @@ char *lzma_decompress_file(const char *filename, off_t *r_size)
- 	off_t size, allocated;
- 	ssize_t result;
- 
--	if (!filename) {
--		*r_size = 0;
--		return 0;
--	}
-+	dbgprintf("Try LZMA decompression.\n");
-+
-+	*r_size = 0;
-+	if (!filename)
-+		return NULL;
-+
- 	fp = lzopen(filename, "rb");
- 	if (fp == 0) {
--		die("Cannot open `%s'\n", filename);
-+		dbgprintf("Cannot open `%s'\n", filename);
-+		return NULL;
- 	}
- 	size = 0;
- 	allocated = 65536;
-@@ -183,17 +186,25 @@ char *lzma_decompress_file(const char *filename, off_t *r_size)
- 			if ((errno == EINTR) || (errno == EAGAIN))
- 				continue;
- 
--			die ("read on %s of %ld bytes failed\n",
--				filename, (allocated - size) + 0UL);
-+			dbgprintf("%s: read on %s of %ld bytes failed\n",
-+				__func__, filename, (allocated - size) + 0UL);
-+			break;
- 		}
- 		size += result;
--	} while(result > 0);
--	result = lzclose(fp);
--	if (result != LZMA_OK) {
--		die ("Close of %s failed\n", filename);
-+	} while (result > 0);
-+
-+	if (lzclose(fp) != LZMA_OK) {
-+		dbgprintf("%s: Close of %s failed\n", __func__, filename);
-+		goto fail;
- 	}
-+	if (result < 0)
-+		goto fail;
-+
- 	*r_size =  size;
- 	return buf;
-+fail:
-+	free(buf);
-+	return NULL;
- }
- #else
- char *lzma_decompress_file(const char *UNUSED(filename), off_t *UNUSED(r_size))
-diff --git a/kexec/zlib.c b/kexec/zlib.c
-index d44df12..7170ac3 100644
---- a/kexec/zlib.c
-+++ b/kexec/zlib.c
-@@ -15,29 +15,39 @@
- #include <ctype.h>
- #include <zlib.h>
- 
-+static void _gzerror(gzFile fp, int *errnum, const char **errmsg)
-+{
-+	*errmsg = gzerror(fp, errnum);
-+	if (*errnum == Z_ERRNO) {
-+		*errmsg = strerror(*errnum);
-+	}
-+}
-+
- char *zlib_decompress_file(const char *filename, off_t *r_size)
- {
- 	gzFile fp;
- 	int errnum;
- 	const char *msg;
- 	char *buf;
--	off_t size, allocated;
-+	off_t size = 0, allocated;
- 	ssize_t result;
- 
-+	dbgprintf("Try gzip decompression.\n");
-+
-+	*r_size = 0;
- 	if (!filename) {
--		*r_size = 0;
--		return 0;
-+		return NULL;
- 	}
- 	fp = gzopen(filename, "rb");
- 	if (fp == 0) {
--		msg = gzerror(fp, &errnum);
--		if (errnum == Z_ERRNO) {
--			msg = strerror(errno);
--		}
--		fprintf(stderr, "Cannot open `%s': %s\n", filename, msg);
-+		_gzerror(fp, &errnum, &msg);
-+		dbgprintf("Cannot open `%s': %s\n", filename, msg);
-+		return NULL;
-+	}
-+	if (gzdirect(fp)) {
-+		/* It's not in gzip format */
- 		return NULL;
- 	}
--	size = 0;
- 	allocated = 65536;
- 	buf = xmalloc(allocated);
- 	do {
-@@ -49,25 +59,28 @@ char *zlib_decompress_file(const char *filename, off_t *r_size)
- 		if (result < 0) {
- 			if ((errno == EINTR) || (errno == EAGAIN))
- 				continue;
--
--			msg = gzerror(fp, &errnum);
--			if (errnum == Z_ERRNO) {
--				msg = strerror(errno);
--			}
--			die ("read on %s of %ld bytes failed: %s\n",
--				filename, (allocated - size) + 0UL, msg);
-+			_gzerror(fp, &errnum, &msg);
-+			dbgprintf("Read on %s of %ld bytes failed: %s\n",
-+					filename, (allocated - size) + 0UL, msg);
-+			size = 0;
-+			goto fail;
- 		}
- 		size += result;
- 	} while(result > 0);
-+
-+fail:
- 	result = gzclose(fp);
- 	if (result != Z_OK) {
--		msg = gzerror(fp, &errnum);
--		if (errnum == Z_ERRNO) {
--			msg = strerror(errno);
--		}
--		die ("Close of %s failed: %s\n", filename, msg);
-+		_gzerror(fp, &errnum, &msg);
-+		dbgprintf(" Close of %s failed: %s\n", filename, msg);
-+	}
-+
-+	if (size > 0) {
-+		*r_size = size;
-+	} else {
-+		free(buf);
-+		buf = NULL;
- 	}
--	*r_size =  size;
- 	return buf;
- }
- #else
-1.7.10.4
-

+ 0 - 51
package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch

@@ -1,52 +0,0 @@
-From eb20884c9bbc42bdf1ccace4444f3ce72657d7d8 Mon Sep 17 00:00:00 2001
-From: Yousong Zhou <yszhou4tech@gmail.com>
-Date: Tue, 9 Sep 2014 20:15:16 +0800
-Subject: [PATCH 2/5] configure.ac: apply necessary quotes to result of macro
- expansion.
-
-This can fix the following error when searching for lzma support and
-while at it also apply the practice to other uses of the same pattern.
-
-	checking for lzma_code in -llzma... ./configure: line 4756: ac_fn_c_try_link: command not found
-
-Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
----
- configure.ac |   12 ++++++------
- 1 file changed, 6 insertions(+), 6 deletions(-)
-
-diff --git a/configure.ac b/configure.ac
-index db93331..c410e90 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -152,22 +152,22 @@ AC_CHECK_PROG([DIRNAME],  dirname,  dirname,  "no", [$PATH])
- dnl See if I have a usable copy of zlib available
- if test "$with_zlib" = yes ; then
- 	AC_CHECK_HEADER(zlib.h,
--		AC_CHECK_LIB(z, inflateInit_, ,
--		AC_MSG_NOTICE([zlib support disabled])))
-+		[AC_CHECK_LIB(z, inflateInit_, ,
-+		AC_MSG_NOTICE([zlib support disabled]))])
- fi
- 
- dnl See if I have a usable copy of lzma available
- if test "$with_lzma" = yes ; then
- 	AC_CHECK_HEADER(lzma.h,
--		AC_CHECK_LIB(lzma, lzma_code, ,
--		AC_MSG_NOTICE([lzma support disabled])))
-+		[AC_CHECK_LIB(lzma, lzma_code, ,
-+		AC_MSG_NOTICE([lzma support disabled]))])
- fi
- 
- dnl find Xen control stack libraries
- if test "$with_xen" = yes ; then
- 	AC_CHECK_HEADER(xenctrl.h,
--		AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
--		AC_MSG_NOTICE([Xen support disabled])))
-+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
-+		AC_MSG_NOTICE([Xen support disabled]))])
- fi
- 
- dnl ---Sanity checks
-1.7.10.4
-

+ 0 - 34
package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch

@@ -1,35 +0,0 @@
-From 89d455d785190203b1d3a8766c8babb8c1688fc3 Mon Sep 17 00:00:00 2001
-From: Yousong Zhou <yszhou4tech@gmail.com>
-Date: Mon, 9 Feb 2015 19:51:25 +0800
-Subject: [PATCH 3/5] mips: fix compiler warning on printing 64-bit integer.
-
-
-Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
----
- kexec/arch/mips/crashdump-mips.c |    3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
-index e7840e0..98c9f7c 100644
---- a/kexec/arch/mips/crashdump-mips.c
-+++ b/kexec/arch/mips/crashdump-mips.c
-@@ -22,6 +22,7 @@
- #include <stdlib.h>
- #include <errno.h>
- #include <limits.h>
-+#include <inttypes.h>
- #include <elf.h>
- #include <sys/types.h>
- #include <sys/stat.h>
-@@ -52,7 +53,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info)
- 
- 	if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) {
- 		elf_info->kern_paddr_start = start;
--		dbgprintf("kernel load physical addr start = 0x%lx\n", start);
-+		dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start);
- 		return 0;
- 	}
- 
-1.7.10.4
-

+ 0 - 29
package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch

@@ -1,30 +0,0 @@
-From 904e9ae892b0592c916a013869e3be3d830e0155 Mon Sep 17 00:00:00 2001
-From: Yousong Zhou <yszhou4tech@gmail.com>
-Date: Mon, 9 Feb 2015 20:11:04 +0800
-Subject: [PATCH 4/5] mips: remove unused variable.
-
-Fixes the following compilation warning.
-
-	kexec/arch/mips/crashdump-mips.c:151:6: warning: unused variable 'i' [-Wunused-variable]
-
-Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
----
- kexec/arch/mips/crashdump-mips.c |    2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
-index 98c9f7c..dc68cb4 100644
---- a/kexec/arch/mips/crashdump-mips.c
-+++ b/kexec/arch/mips/crashdump-mips.c
-@@ -148,7 +148,7 @@ static int exclude_crash_reserve_region(int *nr_ranges)
- static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
- {
- 	const char iomem[] = "/proc/iomem";
--	int i, memory_ranges = 0;
-+	int memory_ranges = 0;
- 	char line[MAX_LINE];
- 	FILE *fp;
- 	unsigned long long start, end;
-1.7.10.4
-

+ 0 - 29
package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch

@@ -1,30 +0,0 @@
-From 00e75179b3b4b80e6e58d29a2bd948f97682fd00 Mon Sep 17 00:00:00 2001
-From: Yousong Zhou <yszhou4tech@gmail.com>
-Date: Mon, 9 Feb 2015 20:28:14 +0800
-Subject: [PATCH 5/5] mips: fix warning about implicit type conversion.
-
-Fixes the following warning.
-
-	kexec/arch/mips/kexec-elf-mips.c:161:16: warning: assignment makes integer from pointer without a cast [enabled by default]
-
-Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
----
- kexec/arch/mips/kexec-elf-mips.c |    2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
-index a27d986..8a6419a 100644
---- a/kexec/arch/mips/kexec-elf-mips.c
-+++ b/kexec/arch/mips/kexec-elf-mips.c
-@@ -158,7 +158,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
- 	if (info->kexec_flags & KEXEC_ON_CRASH)
- 		/* In case of crashdump segment[0] is kernel.
- 		 * Put cmdline just after it. */
--		cmdline_addr = info->segment[0].mem +
-+		cmdline_addr = (unsigned long)info->segment[0].mem +
- 				info->segment[0].memsz;
- 	else
- 		cmdline_addr = 0;
-1.7.10.4
-

+ 20 - 0
package/boot/kexec-tools/patches/100-format_string_fix.patch

@@ -0,0 +1,20 @@
+--- a/kexec/arch/i386/kexec-elf-x86.c
++++ b/kexec/arch/i386/kexec-elf-x86.c
+@@ -296,6 +296,6 @@ out:
+ 	free(command_line);
+ 	free(modified_cmdline);
+ 	if (error_msg)
+-		die(error_msg);
++		die("%s", error_msg);
+ 	return result;
+ }
+--- a/kexec/arch/x86_64/kexec-elf-x86_64.c
++++ b/kexec/arch/x86_64/kexec-elf-x86_64.c
+@@ -276,6 +276,6 @@ out:
+ 	free(command_line);
+ 	free(modified_cmdline);
+ 	if (error_msg)
+-		die(error_msg);
++		die("%s", error_msg);
+ 	return result;
+ }

+ 11 - 0
package/boot/kexec-tools/patches/110-fix-vmcore-dmsg-compilation-error.patch

@@ -0,0 +1,11 @@
+--- a/vmcore-dmesg/vmcore-dmesg.c
++++ b/vmcore-dmesg/vmcore-dmesg.c
+@@ -1,6 +1,8 @@
+ #define _XOPEN_SOURCE 600
+ #define _LARGEFILE_SOURCE 1
+ #define _FILE_OFFSET_BITS 64
++#define _GNU_SOURCE
++
+ #include <endian.h>
+ #include <byteswap.h>
+ #include <stdio.h>

+ 46 - 0
package/boot/kobs-ng/Makefile

@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2013-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=kobs-ng
+PKG_VERSION:=5.4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=imx-kobs-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/
+PKG_HASH:=85171b46068ac47c42fedb8104167bf9afd33dd9527ed127e1ca2eb29d7a86bf
+PKG_BUILD_DIR:=$(BUILD_DIR)/imx-kobs-$(PKG_VERSION)
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=COPYING
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/kobs-ng
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=Application for writing bootstreams to NAND flash
+  DEPENDS:=@TARGET_imx6
+endef
+
+define Package/kobs-ng/description
+ The kobs-ng application writes a bootstream to NAND flash with the proper
+ FCB/DBBT headers and replicated streams.
+endef
+
+define Build/Prepare
+	$(call Build/Prepare/Default)
+	echo "const char* git_sha = \"$(PKG_VERSION)\";" > $(PKG_BUILD_DIR)/autoversion.h
+endef
+
+define Package/kobs-ng/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/kobs-ng $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,kobs-ng))

+ 23 - 0
package/boot/kobs-ng/patches/001-compile.patch

@@ -0,0 +1,23 @@
+--- a/src/mtd.c
++++ b/src/mtd.c
+@@ -28,6 +28,7 @@
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <stddef.h>
+ #include <fcntl.h>
+ #include <ctype.h>
+ #include <errno.h>
+--- a/src/mtd.h
++++ b/src/mtd.h
+@@ -25,8 +25,10 @@
+ #ifndef MTD_H
+ #define MTD_H
+ 
++#define _GNU_SOURCE
+ #include <mtd/mtd-user.h>
+ #include <endian.h>
++#include <fcntl.h>
+ 
+ #include "BootControlBlocks.h"
+ #include "rom_nand_hamming_code_ecc.h"

+ 45 - 0
package/boot/kobs-ng/patches/002-add-init-size-param.patch

@@ -0,0 +1,45 @@
+Add --chip_0_size param to override the size of the mtd partition which is
+required if the SPL does not occupy the entire partition. For Gateworks
+Ventana boards the 'uboot' partition contains both the SPL and uboot.
+--- a/src/main.c
++++ b/src/main.c
+@@ -94,6 +94,7 @@ void usage(void)
+ 	"  [KOBS] boot structures config options\n"
+ 	"    --chip_0_device_path=<path> .......... Device of boot (default /dev/mtd0)\n"
+ 	"    --chip_1_device_path=<path> .......... The second chip in case of multichip NAND\n"
++	"    --chip_0_size=<size> ................. Override size of chip_0 device\n"
+ 	"    --search_exponent=<value> ............ NCB field (default 2)\n"
+ 	"    --data_setup_time=<value> ............ NCB field (default 80)\n"
+ 	"    --data_hold_time=<value> ............. NCB field (default 60)\n"
+--- a/src/mtd.c
++++ b/src/mtd.c
+@@ -876,6 +876,11 @@ struct mtd_data *mtd_open(const struct m
+ 			goto out;
+ 		}
+ 
++		/* override MTD size */
++		if (md->cfg.chip_0_size) {
++			miu->size = md->cfg.chip_0_size;
++		}
++
+ 		/* verify it's a nand */
+ 		if (miu->type != MTD_NANDFLASH
+ 			&& miu->type != MTD_MLCNANDFLASH) {
+@@ -3385,7 +3390,7 @@ static const struct {
+ } mtd_int_args[] = {
+ 	ARG_IGNORE(chip_count),
+ 	ARG_IGNORE(chip_0_offset),
+-	ARG_IGNORE(chip_0_size),
++	ARG(chip_0_size),
+ 	ARG_IGNORE(chip_1_offset),
+ 	ARG_IGNORE(chip_1_size),
+ 	ARG(search_exponent),
+@@ -3578,7 +3583,7 @@ void mtd_cfg_dump(struct mtd_config *cfg
+ //	Pd(chip_count);
+ 	Ps(chip_0_device_path);
+ //	Pd(chip_0_offset);
+-//	Pd(chip_0_size);
++	Pd(chip_0_size);
+ 	Ps(chip_1_device_path);
+ //	Pd(chip_1_offset);
+ //	Pd(chip_1_size);

+ 45 - 0
package/boot/kobs-ng/patches/003-raw-mode.patch

@@ -0,0 +1,45 @@
+The downstream Freescale vendor kernel has a patch that allows determining
+if raw NAND flash mode is provided via a debugfs file. This is not present
+in upstream kernels, but the raw access support was added in the 3.19
+kernel, so we will check the kernel version if we can't find the file.
+--- a/src/mtd.c
++++ b/src/mtd.c
+@@ -34,6 +34,7 @@
+ #include <errno.h>
+ #include <sys/types.h>
+ #include <sys/ioctl.h>
++#include <sys/utsname.h>
+ 
+ #include "mtd.h"
+ #include "rand.h"
+@@ -808,15 +809,27 @@ struct mtd_data *mtd_open(const struct m
+ 	md->cfg = *cfg;
+ 
+ 	/* check if use new raw access mode */
++	/* by looking for debugfs from fsl patch */
++	md->raw_mode_flag = 0;
+ 	fp = fopen("/sys/kernel/debug/gpmi-nand/raw_mode", "r");
+ 	if (!fp) {
+-		md->raw_mode_flag = 0;
+-		vp(md, "mtd: use legacy raw access mode\n");
++		/* fallback to kernel version: raw access added in 3.19 */
++		struct utsname uts;
++		if (!uname(&uts)) {
++			int major = 0, minor = 0;
++			sscanf(uts.release, "%d.%d", &major, &minor);
++			vp(md, "mtd: Linux %d.%d\n", major, minor);
++			if ((major << 8 | minor) > (3 << 8 | 18))
++				md->raw_mode_flag = 1;
++		}
+ 	} else {
+ 		fclose(fp);
+ 		md->raw_mode_flag = 1;
+-		vp(md, "mtd: use new bch layout raw access mode\n");
+ 	}
++	if (md->raw_mode_flag)
++		vp(md, "mtd: use new bch layout raw access mode\n");
++	else
++		vp(md, "mtd: use legacy raw access mode\n");
+ 
+ 	if (plat_config_data->m_u32UseMultiBootArea) {
+ 

+ 27 - 0
package/boot/kobs-ng/patches/004-fix-cal_nfc_geometry.patch

@@ -0,0 +1,27 @@
+The Freescale downstream vendor kernel has a patch that exports the bch
+flash geometry via a debugfs file. This is not available in mainline linux
+kernels so the fallback method calculates the geometry based on known info
+from the mtd partition. A bug exists in this funcion where it fails to
+assume that block0 ECC is the same as the other blocks by default.
+--- a/src/mtd.c
++++ b/src/mtd.c
+@@ -610,7 +610,7 @@ static int cal_nfc_geometry(struct mtd_d
+ 	/* The two are fixed, please change them when the driver changes. */
+ 	geo->metadata_size_in_bytes = 10;
+ 	geo->gf_len = 13;
+-	geo->ecc_chunkn_size_in_bytes = 512;
++	geo->ecc_chunkn_size_in_bytes = geo->ecc_chunk0_size_in_bytes = 512;
+ 
+ 	if (mtd->oobsize > geo->ecc_chunkn_size_in_bytes) {
+ 		geo->gf_len = 14;
+@@ -700,8 +700,9 @@ int parse_nfc_geometry(struct mtd_data *
+ 	unsigned int       value;
+ 
+ 	if (!plat_config_data->m_u32UseNfcGeo) {
++		/* fsl kernel patch provides bch_geometry via debugfs */
+ 		if (!(node = fopen(dbg_geometry_node_path, "r"))) {
+-			fprintf(stderr, "Cannot open BCH geometry node: \"%s\"",
++			fprintf(stderr, "Cannot open BCH geometry node: \"%s\"\n",
+ 				dbg_geometry_node_path);
+ 			return cal_nfc_geometry(md);
+ 		}

+ 47 - 0
package/boot/rbcfg/Makefile

@@ -0,0 +1,47 @@
+#
+# Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=rbcfg
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+PKG_FLAGS:=nonshared
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/rbcfg
+  SECTION:=utils
+  CATEGORY:=Utilities
+  SUBMENU:=Boot Loaders
+  TITLE:=RouterBOOT configuration tool
+  DEPENDS:=@TARGET_ar71xx
+endef
+
+define Package/rbcfg/description
+ This package contains an utility to manipulate RouterBOOT configuration on the
+ MikroTIK RB-4XX devices.
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		CC="$(TARGET_CC)" \
+		CFLAGS="$(TARGET_CFLAGS) -Wall" \
+		LDFLAGS="$(TARGET_LDFLAGS)"
+endef
+
+define Package/rbcfg/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/rbcfg $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,rbcfg))

+ 14 - 0
package/boot/rbcfg/src/Makefile

@@ -0,0 +1,14 @@
+CC = gcc
+CFLAGS = -Wall
+OBJS = main.o cyg_crc32.o
+
+all: rbcfg
+
+%.o: %.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+rbcfg: $(OBJS)
+	$(CC) -o $@ $(OBJS)
+
+clean:
+	rm -f rbcfg *.o

+ 109 - 0
package/boot/rbcfg/src/cyg_crc.h

@@ -0,0 +1,109 @@
+//==========================================================================
+//
+//      crc.h
+//
+//      Interface for the CRC algorithms.
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2002 Andrew Lunn
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    Andrew Lunn
+// Contributors: Andrew Lunn
+// Date:         2002-08-06
+// Purpose:
+// Description:
+//
+// This code is part of eCos (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#ifndef _SERVICES_CRC_CRC_H_
+#define _SERVICES_CRC_CRC_H_
+
+#if 0
+#include <cyg/infra/cyg_type.h>
+#else
+#include <stdint.h>
+typedef uint32_t cyg_uint32;
+typedef uint16_t cyg_uint16;
+#endif
+
+#ifndef __externC
+# ifdef __cplusplus
+#  define __externC extern "C"
+# else
+#  define __externC extern
+# endif
+#endif
+
+// Compute a CRC, using the POSIX 1003 definition
+
+__externC cyg_uint32
+cyg_posix_crc32(unsigned char *s, int len);
+
+// Gary S. Brown's 32 bit CRC
+
+__externC cyg_uint32
+cyg_crc32(unsigned char *s, int len);
+
+// Gary S. Brown's 32 bit CRC, but accumulate the result from a
+// previous CRC calculation
+
+__externC cyg_uint32
+cyg_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
+
+// Ethernet FCS Algorithm
+
+__externC cyg_uint32
+cyg_ether_crc32(unsigned char *s, int len);
+
+// Ethernet FCS algorithm, but accumulate the result from a previous
+// CRC calculation.
+
+__externC cyg_uint32
+cyg_ether_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
+
+// 16 bit CRC with polynomial x^16+x^12+x^5+1
+
+__externC cyg_uint16
+cyg_crc16(unsigned char *s, int len);
+
+#endif // _SERVICES_CRC_CRC_H_
+
+
+

+ 172 - 0
package/boot/rbcfg/src/cyg_crc32.c

@@ -0,0 +1,172 @@
+//==========================================================================
+//
+//      crc32.c
+//
+//      Gary S. Brown's 32 bit CRC
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2002 Gary Thomas
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    gthomas
+// Contributors: gthomas,asl
+// Date:         2001-01-31
+// Purpose:      
+// Description:  
+//              
+// This code is part of eCos (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#if 0
+#include <cyg/crc/crc.h>
+#else
+#include "cyg_crc.h"
+#endif
+
+  /* ====================================================================== */
+  /*  COPYRIGHT (C) 1986 Gary S. Brown.  You may use this program, or       */
+  /*  code or tables extracted from it, as desired without restriction.     */
+  /*                                                                        */
+  /*  First, the polynomial itself and its table of feedback terms.  The    */
+  /*  polynomial is                                                         */
+  /*  X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0   */
+  /*                                                                        */
+  /* ====================================================================== */
+
+static const cyg_uint32 crc32_tab[] = {
+      0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+      0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+      0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+      0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+      0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+      0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+      0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+      0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+      0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+      0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+      0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+      0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+      0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+      0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+      0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+      0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+      0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+      0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+      0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+      0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+      0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+      0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+      0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+      0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+      0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+      0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+      0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+      0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+      0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+      0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+      0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+      0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+      0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+      0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+      0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+      0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+      0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+      0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+      0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+      0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+      0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+      0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+      0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+      0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+      0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+      0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+      0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+      0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+      0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+      0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+      0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+      0x2d02ef8dL
+   };
+
+/* This is the standard Gary S. Brown's 32 bit CRC algorithm, but
+   accumulate the CRC into the result of a previous CRC. */
+cyg_uint32 
+cyg_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
+{
+  int i;
+
+  for (i = 0;  i < len;  i++) {
+    crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
+  }
+  return crc32val;
+}
+
+/* This is the standard Gary S. Brown's 32 bit CRC algorithm */
+cyg_uint32
+cyg_crc32(unsigned char *s, int len)
+{
+  return (cyg_crc32_accumulate(0,s,len));
+}
+
+/* Return a 32-bit CRC of the contents of the buffer accumulating the
+   result from a previous CRC calculation. This uses the Ethernet FCS
+   algorithm.*/
+cyg_uint32
+cyg_ether_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
+{
+  int i;
+
+  if (s == 0) return 0L;
+  
+  crc32val = crc32val ^ 0xffffffff;
+  for (i = 0;  i < len;  i++) {
+      crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
+  }
+  return crc32val ^ 0xffffffff;
+}
+
+/* Return a 32-bit CRC of the contents of the buffer, using the
+   Ethernet FCS algorithm. */
+cyg_uint32
+cyg_ether_crc32(unsigned char *s, int len)
+{
+  return cyg_ether_crc32_accumulate(0,s,len);
+}
+
+

+ 791 - 0
package/boot/rbcfg/src/main.c

@@ -0,0 +1,791 @@
+/*
+ *  RouterBOOT configuration utility
+ *
+ *  Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <linux/limits.h>
+
+#include "rbcfg.h"
+#include "cyg_crc.h"
+
+#define RBCFG_TMP_FILE	"/tmp/.rbcfg"
+#define RBCFG_MTD_NAME	"soft_config"
+
+#define RB_ERR_NOTFOUND		1
+#define RB_ERR_INVALID		2
+#define RB_ERR_NOMEM		3
+#define RB_ERR_IO		4
+
+#define ARRAY_SIZE(_a)	(sizeof((_a)) / sizeof((_a)[0]))
+
+struct rbcfg_ctx {
+	char		*mtd_device;
+	char		*tmp_file;
+	char		*buf;
+	unsigned	buflen;
+};
+
+struct rbcfg_value {
+	const char		*name;
+	const char		*desc;
+	union {
+		uint32_t	u32;
+		const char	*raw;
+	} val;
+};
+
+#define RBCFG_ENV_TYPE_U32	0
+
+struct rbcfg_env {
+	const char			*name;
+	int				type;
+	uint16_t			id;
+	const struct rbcfg_value	*values;
+	int				num_values;
+};
+
+#define CMD_FLAG_USES_CFG	0x01
+
+struct rbcfg_command {
+	const char	*command;
+	const char	*usage;
+	int		flags;
+	int		(*exec)(int argc, const char *argv[]);
+};
+
+static void usage(void);
+
+/* Globals */
+
+static struct rbcfg_ctx *rbcfg_ctx;
+static char *rbcfg_name;
+
+#define CFG_U32(_name, _desc, _val) { 	\
+	.name		= (_name),	\
+	.desc		= (_desc),	\
+	.val.u32	= (_val),	\
+}
+
+static const struct rbcfg_value rbcfg_boot_delay[] = {
+	CFG_U32("1", "1 second", RB_BOOT_DELAY_1SEC),
+	CFG_U32("2", "2 seconds", RB_BOOT_DELAY_2SEC),
+	CFG_U32("3", "3 seconds", RB_BOOT_DELAY_3SEC),
+	CFG_U32("4", "4 seconds", RB_BOOT_DELAY_4SEC),
+	CFG_U32("5", "5 seconds", RB_BOOT_DELAY_5SEC),
+	CFG_U32("6", "6 seconds", RB_BOOT_DELAY_6SEC),
+	CFG_U32("7", "7 seconds", RB_BOOT_DELAY_7SEC),
+	CFG_U32("8", "8 seconds", RB_BOOT_DELAY_8SEC),
+	CFG_U32("9", "9 seconds", RB_BOOT_DELAY_9SEC),
+};
+
+static const struct rbcfg_value rbcfg_boot_device[] = {
+	CFG_U32("eth", "boot over Ethernet",
+		RB_BOOT_DEVICE_ETHER),
+	CFG_U32("nandeth", "boot from NAND, if fail then Ethernet",
+		RB_BOOT_DEVICE_NANDETH),
+	CFG_U32("ethnand", "boot Ethernet once, then NAND",
+		RB_BOOT_DEVICE_ETHONCE),
+	CFG_U32("nand", "boot from NAND only",
+		RB_BOOT_DEVICE_NANDONLY),
+};
+
+static const struct rbcfg_value rbcfg_boot_key[] = {
+	CFG_U32("any", "any key", RB_BOOT_KEY_ANY),
+	CFG_U32("del", "<Delete> key only", RB_BOOT_KEY_DEL),
+};
+
+static const struct rbcfg_value rbcfg_boot_protocol[] = {
+	CFG_U32("bootp", "BOOTP protocol", RB_BOOT_PROTOCOL_BOOTP),
+	CFG_U32("dhcp", "DHCP protocol", RB_BOOT_PROTOCOL_DHCP),
+};
+
+static const struct rbcfg_value rbcfg_uart_speed[] = {
+	CFG_U32("115200", "", RB_UART_SPEED_115200),
+	CFG_U32("57600", "", RB_UART_SPEED_57600),
+	CFG_U32("38400", "", RB_UART_SPEED_38400),
+	CFG_U32("19200", "", RB_UART_SPEED_19200),
+	CFG_U32("9600", "", RB_UART_SPEED_9600),
+	CFG_U32("4800", "", RB_UART_SPEED_4800),
+	CFG_U32("2400", "", RB_UART_SPEED_2400),
+	CFG_U32("1200", "", RB_UART_SPEED_1200),
+	CFG_U32("off", "disable console output", RB_UART_SPEED_OFF),
+};
+
+static const struct rbcfg_value rbcfg_cpu_mode[] = {
+	CFG_U32("powersave", "power save", RB_CPU_MODE_POWERSAVE),
+	CFG_U32("regular", "regular (better for -0c environment)",
+		RB_CPU_MODE_REGULAR),
+};
+
+static const struct rbcfg_value rbcfg_booter[] = {
+	CFG_U32("regular", "load regular booter", RB_BOOTER_REGULAR),
+	CFG_U32("backup", "force backup-booter loading", RB_BOOTER_BACKUP),
+};
+
+static const struct rbcfg_env rbcfg_envs[] = {
+	{
+		.name		= "boot_delay",
+		.id		= RB_ID_BOOT_DELAY,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_boot_delay,
+		.num_values	= ARRAY_SIZE(rbcfg_boot_delay),
+	}, {
+		.name		= "boot_device",
+		.id		= RB_ID_BOOT_DEVICE,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_boot_device,
+		.num_values	= ARRAY_SIZE(rbcfg_boot_device),
+	}, {
+		.name		= "boot_key",
+		.id		= RB_ID_BOOT_KEY,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_boot_key,
+		.num_values	= ARRAY_SIZE(rbcfg_boot_key),
+	}, {
+		.name		= "boot_protocol",
+		.id		= RB_ID_BOOT_PROTOCOL,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_boot_protocol,
+		.num_values	= ARRAY_SIZE(rbcfg_boot_protocol),
+	}, {
+		.name		= "booter",
+		.id		= RB_ID_BOOTER,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_booter,
+		.num_values	= ARRAY_SIZE(rbcfg_booter),
+	}, {
+		.name		= "cpu_mode",
+		.id		= RB_ID_CPU_MODE,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_cpu_mode,
+		.num_values	= ARRAY_SIZE(rbcfg_cpu_mode),
+	}, {
+		.name		= "uart_speed",
+		.id		= RB_ID_UART_SPEED,
+		.type		= RBCFG_ENV_TYPE_U32,
+		.values		= rbcfg_uart_speed,
+		.num_values	= ARRAY_SIZE(rbcfg_uart_speed),
+	}
+};
+
+static inline uint16_t
+get_u16(const void *buf)
+{
+	const uint8_t *p = buf;
+
+	return ((uint16_t) p[1] + ((uint16_t) p[0] << 8));
+}
+
+static inline uint32_t
+get_u32(const void *buf)
+{
+	const uint8_t *p = buf;
+
+	return ((uint32_t) p[3] + ((uint32_t) p[2] << 8) +
+	       ((uint32_t) p[1] << 16) + ((uint32_t) p[0] << 24));
+}
+
+static inline void
+put_u32(void *buf, uint32_t val)
+{
+	uint8_t *p = buf;
+
+	p[3] = val & 0xff;
+	p[2] = (val >> 8) & 0xff;
+	p[1] = (val >> 16) & 0xff;
+	p[0] = (val >> 24) & 0xff;
+}
+
+static int
+rbcfg_find_tag(struct rbcfg_ctx *ctx, uint16_t tag_id, uint16_t *tag_len,
+	       void **tag_data)
+{
+	uint16_t id;
+	uint16_t len;
+	char *buf = ctx->buf;
+	unsigned int buflen = ctx->buflen;
+	int ret = RB_ERR_NOTFOUND;
+
+	/* skip magic and CRC value */
+	buf += 8;
+	buflen -= 8;
+
+	while (buflen > 2) {
+		len = get_u16(buf);
+		buf += 2;
+		buflen -= 2;
+
+		if (buflen < 2)
+			break;
+
+		id = get_u16(buf);
+		buf += 2;
+		buflen -= 2;
+
+		if (id == RB_ID_TERMINATOR)
+			break;
+
+		if (buflen < len)
+			break;
+
+		if (id == tag_id) {
+			*tag_len = len;
+			*tag_data = buf;
+			ret = 0;
+			break;
+		}
+
+		buf += len;
+		buflen -= len;
+	}
+
+	if (ret)
+		fprintf(stderr, "no tag found with id=%u\n", tag_id);
+
+	return ret;
+}
+
+static int
+rbcfg_get_u32(struct rbcfg_ctx *ctx, uint16_t id, uint32_t *val)
+{
+	void *tag_data;
+	uint16_t tag_len;
+	int err;
+
+	err = rbcfg_find_tag(ctx, id, &tag_len, &tag_data);
+	if (err)
+		return err;
+
+	*val = get_u32(tag_data);
+	return 0;
+}
+
+static int
+rbcfg_set_u32(struct rbcfg_ctx *ctx, uint16_t id, uint32_t val)
+{
+	void *tag_data;
+	uint16_t tag_len;
+	int err;
+
+	err = rbcfg_find_tag(ctx, id, &tag_len, &tag_data);
+	if (err)
+		return err;
+
+	put_u32(tag_data, val);
+	return 0;
+}
+
+char *rbcfg_find_mtd(const char *name, int *erase_size)
+{
+	FILE *f;
+	int mtd_num;
+	char dev[PATH_MAX];
+	char *ret = NULL;
+	struct stat s;
+	int err;
+
+	f = fopen("/proc/mtd", "r");
+	if (!f)
+		return NULL;
+
+	while (1) {
+		char *p;
+		p = fgets(dev, sizeof(dev), f);
+		if (!p)
+			break;
+
+		if (!strstr(dev, name))
+			continue;
+
+		err = sscanf(dev, "mtd%d: %08x", &mtd_num, erase_size);
+		if (err != 2)
+			break;
+
+		sprintf(dev, "/dev/mtdblock%d", mtd_num);
+		err = stat(dev, &s);
+		if (err < 0)
+			break;
+
+		if ((s.st_mode & S_IFBLK) == 0)
+			break;
+
+		ret = malloc(strlen(dev) + 1);
+		if (ret == NULL)
+			break;
+
+		strncpy(ret, dev, strlen(dev) + 1);
+		break;
+	}
+
+	fclose(f);
+	return ret;
+}
+
+static int
+rbcfg_check_tmp(struct rbcfg_ctx *ctx)
+{
+	struct stat s;
+	int err;
+
+	err = stat(ctx->tmp_file, &s);
+	if (err < 0)
+		return 0;
+
+	if ((s.st_mode & S_IFREG) == 0)
+		return 0;
+
+	if (s.st_size != ctx->buflen)
+		return 0;
+
+	return 1;
+}
+
+static int
+rbcfg_load(struct rbcfg_ctx *ctx)
+{
+	uint32_t magic;
+	uint32_t crc_orig, crc;
+	char *name;
+	int tmp;
+	int fd;
+	int err;
+
+	tmp = rbcfg_check_tmp(ctx);
+	name = (tmp) ? ctx->tmp_file : ctx->mtd_device;
+
+	fd = open(name, O_RDONLY);
+	if (fd < 0) {
+		fprintf(stderr, "unable to open %s\n", name);
+		err = RB_ERR_IO;
+		goto err;
+	}
+
+	err = read(fd, ctx->buf, ctx->buflen);
+	if (err != ctx->buflen) {
+		fprintf(stderr, "unable to read from %s\n", name);
+		err = RB_ERR_IO;
+		goto err_close;
+	}
+
+	magic = get_u32(ctx->buf);
+	if (magic != RB_MAGIC_SOFT) {
+		fprintf(stderr, "invalid configuration\n");
+		err = RB_ERR_INVALID;
+		goto err_close;
+	}
+
+	crc_orig = get_u32(ctx->buf + 4);
+	put_u32(ctx->buf + 4, 0);
+	crc = cyg_ether_crc32((unsigned char *) ctx->buf, ctx->buflen);
+	if (crc != crc_orig) {
+		fprintf(stderr, "configuration has CRC error\n");
+		err = RB_ERR_INVALID;
+		goto err_close;
+	}
+
+	err = 0;
+
+ err_close:
+	close(fd);
+ err:
+	return err;
+}
+
+static int
+rbcfg_open()
+{
+	char *mtd_device;
+	struct rbcfg_ctx *ctx;
+	int buflen;
+	int err;
+
+	mtd_device = rbcfg_find_mtd(RBCFG_MTD_NAME, &buflen);
+	if (!mtd_device) {
+		fprintf(stderr, "unable to find configuration\n");
+		return RB_ERR_NOTFOUND;
+	}
+
+	ctx = malloc(sizeof(struct rbcfg_ctx) + buflen);
+	if (ctx == NULL) {
+		err = RB_ERR_NOMEM;
+		goto err_free_mtd;
+	}
+
+	ctx->mtd_device = mtd_device;
+	ctx->tmp_file = RBCFG_TMP_FILE;
+	ctx->buflen = buflen;
+	ctx->buf = (char *) &ctx[1];
+
+	err = rbcfg_load(ctx);
+	if (err)
+		goto err_free_ctx;
+
+	rbcfg_ctx = ctx;
+	return 0;
+
+ err_free_ctx:
+	free(ctx);
+ err_free_mtd:
+	free(mtd_device);
+	return err;
+}
+
+static int
+rbcfg_update(int tmp)
+{
+	struct rbcfg_ctx *ctx = rbcfg_ctx;
+	char *name;
+	uint32_t crc;
+	int fd;
+	int err;
+
+	put_u32(ctx->buf, RB_MAGIC_SOFT);
+	put_u32(ctx->buf + 4, 0);
+	crc = cyg_ether_crc32((unsigned char *) ctx->buf, ctx->buflen);
+	put_u32(ctx->buf + 4, crc);
+
+	name = (tmp) ? ctx->tmp_file : ctx->mtd_device;
+	fd = open(name, O_WRONLY | O_CREAT);
+	if (fd < 0) {
+		fprintf(stderr, "unable to open %s for writing\n", name);
+		err = RB_ERR_IO;
+		goto out;
+	}
+
+	err = write(fd, ctx->buf, ctx->buflen);
+	if (err != ctx->buflen) {
+		err = RB_ERR_IO;
+		goto out_close;
+	}
+
+	fsync(fd);
+	err = 0;
+
+ out_close:
+	close(fd);
+ out:
+	return err;
+}
+
+static void
+rbcfg_close(void)
+{
+	struct rbcfg_ctx *ctx;
+
+	ctx = rbcfg_ctx;
+	free(ctx->mtd_device);
+	free(ctx);
+}
+
+static const struct rbcfg_value *
+rbcfg_env_find(const struct rbcfg_env *env, const char *name)
+{
+	unsigned i;
+
+	for (i = 0; i < env->num_values; i++) {
+		const struct rbcfg_value *v = &env->values[i];
+
+		if (strcmp(v->name, name) == 0)
+			return v;
+	}
+
+	return NULL;
+}
+
+static const struct rbcfg_value *
+rbcfg_env_find_u32(const struct rbcfg_env *env, uint32_t val)
+{
+	unsigned i;
+
+	for (i = 0; i < env->num_values; i++) {
+		const struct rbcfg_value *v = &env->values[i];
+
+		if (v->val.u32 == val)
+			return v;
+	}
+
+	return NULL;
+}
+
+static const char *
+rbcfg_env_get_u32(const struct rbcfg_env *env)
+{
+	const struct rbcfg_value *v;
+	uint32_t val;
+	int err;
+
+	err = rbcfg_get_u32(rbcfg_ctx, env->id, &val);
+	if (err)
+		return NULL;
+
+	v = rbcfg_env_find_u32(env, val);
+	if (v == NULL) {
+		fprintf(stderr, "unknown value %08x found for %s\n",
+			val, env->name);
+		return NULL;
+	}
+
+	return v->name;
+}
+
+static int
+rbcfg_env_set_u32(const struct rbcfg_env *env, const char *data)
+{
+	const struct rbcfg_value *v;
+	int err;
+
+	v = rbcfg_env_find(env, data);
+	if (v == NULL) {
+		fprintf(stderr, "invalid value '%s'\n", data);
+		return RB_ERR_INVALID;
+	}
+
+	err = rbcfg_set_u32(rbcfg_ctx, env->id, v->val.u32);
+	return err;
+}
+
+static const char *
+rbcfg_env_get(const struct rbcfg_env *env)
+{
+	const char *ret = NULL;
+
+	switch (env->type) {
+	case RBCFG_ENV_TYPE_U32:
+		ret = rbcfg_env_get_u32(env);
+		break;
+	}
+
+	return ret;
+}
+
+static int
+rbcfg_env_set(const struct rbcfg_env *env, const char *data)
+{
+	int ret = 0;
+
+	switch (env->type) {
+	case RBCFG_ENV_TYPE_U32:
+		ret = rbcfg_env_set_u32(env, data);
+		break;
+	}
+
+	return ret;
+}
+
+static int
+rbcfg_cmd_apply(int argc, const char *argv[])
+{
+	return rbcfg_update(0);
+}
+
+static int
+rbcfg_cmd_help(int argc, const char *argv[])
+{
+	usage();
+	return 0;
+}
+
+static int
+rbcfg_cmd_get(int argc, const char *argv[])
+{
+	int err = RB_ERR_NOTFOUND;
+	int i;
+
+	if (argc != 1) {
+		usage();
+		return RB_ERR_INVALID;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+		const struct rbcfg_env *env = &rbcfg_envs[i];
+		const char *value;
+
+		if (strcmp(env->name, argv[0]))
+			continue;
+
+		value = rbcfg_env_get(env);
+		if (value) {
+			fprintf(stdout, "%s\n", value);
+			err = 0;
+		}
+		break;
+	}
+
+	return err;
+}
+
+static int
+rbcfg_cmd_set(int argc, const char *argv[])
+{
+	int err = RB_ERR_INVALID;
+	int i;
+
+	if (argc != 2) {
+		/* not enough parameters */
+		usage();
+		return RB_ERR_INVALID;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+		const struct rbcfg_env *env = &rbcfg_envs[i];
+
+		if (strcmp(env->name, argv[0]))
+			continue;
+
+		err = rbcfg_env_set(env, argv[1]);
+		if (err == 0)
+			err = rbcfg_update(1);
+		break;
+	}
+
+	return err;
+}
+
+static int
+rbcfg_cmd_show(int argc, const char *argv[])
+{
+	int i;
+
+	if (argc != 0) {
+		usage();
+		return RB_ERR_INVALID;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+		const struct rbcfg_env *env = &rbcfg_envs[i];
+		const char *value;
+
+		value = rbcfg_env_get(env);
+		if (value)
+			fprintf(stdout, "%s=%s\n", env->name, value);
+	}
+
+	return 0;
+}
+
+static const struct rbcfg_command rbcfg_commands[] = {
+	{
+		.command	= "apply",
+		.usage		= "apply\n"
+				  "\t- write configuration to the mtd device",
+		.flags		= CMD_FLAG_USES_CFG,
+		.exec		= rbcfg_cmd_apply,
+	}, {
+		.command	= "help",
+		.usage		= "help\n"
+				  "\t- show this screen",
+		.exec		= rbcfg_cmd_help,
+	}, {
+		.command	= "get",
+		.usage		= "get <name>\n"
+				  "\t- get value of the configuration option <name>",
+		.flags		= CMD_FLAG_USES_CFG,
+		.exec		= rbcfg_cmd_get,
+	}, {
+		.command	= "set",
+		.usage		= "set <name> <value>\n"
+				  "\t- set value of the configuration option <name> to <value>",
+		.flags		= CMD_FLAG_USES_CFG,
+		.exec		= rbcfg_cmd_set,
+	}, {
+		.command	= "show",
+		.usage		= "show\n"
+				  "\t- show value of all configuration options",
+		.flags		= CMD_FLAG_USES_CFG,
+		.exec		= rbcfg_cmd_show,
+	}
+};
+
+static void
+usage(void)
+{
+	char buf[255];
+	int len;
+	int i;
+
+	fprintf(stderr, "Usage: %s <command>\n", rbcfg_name);
+
+	fprintf(stderr, "\nCommands:\n");
+	for (i = 0; i < ARRAY_SIZE(rbcfg_commands); i++) {
+		const struct rbcfg_command *cmd;
+		cmd = &rbcfg_commands[i];
+
+		len = snprintf(buf, sizeof(buf), "%s", cmd->usage);
+		buf[len] = '\0';
+		fprintf(stderr, "%s\n", buf);
+	}
+
+	fprintf(stderr, "\nConfiguration options:\n");
+	for (i = 0; i < ARRAY_SIZE(rbcfg_envs); i++) {
+		const struct rbcfg_env *env;
+		int j;
+
+		env = &rbcfg_envs[i];
+		fprintf(stderr, "\n%s:\n", env->name);
+		for (j = 0; j < env->num_values; j++) {
+			const struct rbcfg_value *v = &env->values[j];
+			fprintf(stderr, "\t%-12s %s\n", v->name, v->desc);
+		}
+	}
+	fprintf(stderr, "\n");
+}
+
+int main(int argc, const char *argv[])
+{
+	const struct rbcfg_command *cmd = NULL;
+	int ret;
+	int i;
+
+	rbcfg_name = (char *) argv[0];
+
+	if (argc < 2) {
+		usage();
+		return EXIT_FAILURE;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(rbcfg_commands); i++) {
+		if (strcmp(rbcfg_commands[i].command, argv[1]) == 0) {
+			cmd = &rbcfg_commands[i];
+			break;
+		}
+	}
+
+	if (cmd == NULL) {
+		fprintf(stderr, "unknown command '%s'\n", argv[1]);
+		usage();
+		return EXIT_FAILURE;
+	}
+
+	argc -= 2;
+	argv += 2;
+
+	if (cmd->flags & CMD_FLAG_USES_CFG) {
+		ret = rbcfg_open();
+		if (ret)
+			return EXIT_FAILURE;
+	}
+
+	ret = cmd->exec(argc, argv);
+
+	if (cmd->flags & CMD_FLAG_USES_CFG)
+		rbcfg_close();
+
+	if (ret)
+		return EXIT_FAILURE;
+
+	return EXIT_SUCCESS;
+}

+ 75 - 0
package/boot/rbcfg/src/rbcfg.h

@@ -0,0 +1,75 @@
+/*
+ *  Mikrotik's RouterBOOT configuration defines
+ *
+ *  Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#ifndef _RBCFG_H
+#define _RBCFG_H
+
+/*
+ * Magic numbers
+ */
+#define RB_MAGIC_SOFT	0x74666f53 /* 'Soft' */
+
+/*
+ * ID values for Software settings
+ */
+#define RB_ID_TERMINATOR	0
+#define RB_ID_UART_SPEED	1
+#define RB_ID_BOOT_DELAY	2
+#define RB_ID_BOOT_DEVICE	3
+#define RB_ID_BOOT_KEY		4
+#define RB_ID_CPU_MODE		5
+#define RB_ID_FW_VERSION	6
+#define RB_ID_SOFT_07		7
+#define RB_ID_SOFT_08		8
+#define RB_ID_BOOT_PROTOCOL	9
+#define RB_ID_SOFT_10		10
+#define RB_ID_SOFT_11		11
+#define RB_ID_BOOTER		13
+
+#define RB_UART_SPEED_115200	0
+#define RB_UART_SPEED_57600	1
+#define RB_UART_SPEED_38400	2
+#define RB_UART_SPEED_19200	3
+#define RB_UART_SPEED_9600	4
+#define RB_UART_SPEED_4800	5
+#define RB_UART_SPEED_2400	6
+#define RB_UART_SPEED_1200	7
+#define RB_UART_SPEED_OFF	8
+
+#define RB_BOOT_DELAY_1SEC	1
+#define RB_BOOT_DELAY_2SEC	2
+#define RB_BOOT_DELAY_3SEC	3
+#define RB_BOOT_DELAY_4SEC	4
+#define RB_BOOT_DELAY_5SEC	5
+#define RB_BOOT_DELAY_6SEC	6
+#define RB_BOOT_DELAY_7SEC	7
+#define RB_BOOT_DELAY_8SEC	8
+#define RB_BOOT_DELAY_9SEC	9
+
+#define RB_BOOT_DEVICE_ETHER	0
+#define RB_BOOT_DEVICE_NANDETH	1
+#define RB_BOOT_DEVICE_CFCARD	2
+#define RB_BOOT_DEVICE_ETHONCE	3
+#define RB_BOOT_DEVICE_NANDONLY	5
+
+#define RB_BOOT_KEY_ANY		0
+#define RB_BOOT_KEY_DEL		1
+
+#define RB_CPU_MODE_POWERSAVE	0
+#define RB_CPU_MODE_REGULAR	1
+
+#define RB_BOOT_PROTOCOL_BOOTP	0
+#define RB_BOOT_PROTOCOL_DHCP	1
+
+#define RB_BOOTER_REGULAR	0
+#define RB_BOOTER_BACKUP	1
+
+#endif /* _RBCFG_H */

+ 3 - 1
package/boot/yamonenv/Makefile

@@ -13,10 +13,12 @@ PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)_gruen.4g__$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://downloads.openwrt.org/sources/
-PKG_MD5SUM:=a3e4f24155aa3ba5aa502bc63fdaa6ad
+PKG_HASH:=466eca9cdad2c15e957fb9ce7d0b6927ecd17d85c4cc2dff37e97a3e6b209c67
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
 
+PKG_FLAGS:=nonshared
+
 include $(INCLUDE_DIR)/package.mk
 
 define Package/yamonenv

+ 0 - 35
package/kernel/avila-wdt/Makefile

@@ -1,35 +0,0 @@
-#