Skip to content

Commit

Permalink
ramips: mt7621: add support for Netgear R6800
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsnowwolf committed Dec 13, 2019
1 parent ca61310 commit 7ea08e9
Show file tree
Hide file tree
Showing 493 changed files with 11,714 additions and 6,963 deletions.
51 changes: 29 additions & 22 deletions include/image-commands.mk
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,21 @@ endef
# append a fake/empty uImage header, to fool bootloaders rootfs integrity check
# for example
define Build/append-uImage-fakehdr
$(eval type=$(word 1,$(1)))
$(eval magic=$(word 2,$(1)))
touch $@.fakehdr
$(STAGING_DIR_HOST)/bin/mkimage \
-A $(LINUX_KARCH) -O linux -T $(1) -C none \
-n '$(VERSION_DIST) fake $(1)' \
-A $(LINUX_KARCH) -O linux -T $(type) -C none \
-n '$(VERSION_DIST) fake $(type)' \
$(if $(magic),-M $(magic)) \
-d $@.fakehdr \
-s \
$@.fakehdr
cat $@.fakehdr >> $@
endef

define Build/tplink-safeloader
-$(STAGING_DIR_HOST)/bin/tplink-safeloader \
-$(STAGING_DIR_HOST)/bin/tplink-safeloader \
-B $(TPLINK_BOARD_ID) \
-V $(REVISION) \
-k $(IMAGE_KERNEL) \
Expand All @@ -131,25 +134,18 @@ define Build/tplink-safeloader
$(if $(findstring sysupgrade,$(word 1,$(1))),-S) && mv $@.new $@ || rm -f $@
endef

define Build/mksercommfw
-$(STAGING_DIR_HOST)/bin/mksercommfw \
$@ \
$(KERNEL_OFFSET) \
$(HWID) \
$(HWVER) \
$(SWVER)
endef


define Build/append-dtb
cat $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb >> $@
endef

define Build/install-dtb
$(foreach dts,$(DEVICE_DTS), \
$(CP) \
$(DTS_DIR)/$(dts).dtb \
$(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
$(call locked, \
$(foreach dts,$(DEVICE_DTS), \
$(CP) \
$(DTS_DIR)/$(dts).dtb \
$(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
), \
install-dtb-$(IMG_PREFIX) \
)
endef

Expand Down Expand Up @@ -178,6 +174,16 @@ define Build/gzip
@mv $@.new $@
endef

define Build/zip
mkdir $@.tmp
mv $@ $@.tmp/$(1)

zip -j -X \
$(if $(SOURCE_DATE_EPOCH),--mtime="$(SOURCE_DATE_EPOCH)") \
$@ $@.tmp/$(if $(1),$(1),$@)
rm -rf $@.tmp
endef

define Build/jffs2
rm -rf $(KDIR_TMP)/$(DEVICE_NAME)/jffs2 && \
mkdir -p $(KDIR_TMP)/$(DEVICE_NAME)/jffs2/$$(dirname $(1)) && \
Expand Down Expand Up @@ -230,8 +236,7 @@ define Build/append-uboot
endef

define Build/pad-to
dd if=$@ of=$@.new bs=$(1) conv=sync
mv $@.new $@
$(call Image/pad-to,$@,$(1))
endef

define Build/pad-extra
Expand Down Expand Up @@ -297,14 +302,14 @@ endef
define Build/qsdk-ipq-factory-nand
$(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
$@.its ubi $@
mkimage -f $@.its $@.new
PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
@mv $@.new $@
endef

define Build/qsdk-ipq-factory-nor
$(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
$@.its hlos $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS)
mkimage -f $@.its $@.new
PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
@mv $@.new $@
endef

Expand Down Expand Up @@ -355,12 +360,14 @@ json_quote=$(subst ','\'',$(subst ",\",$(1)))
metadata_devices=$(if $(1),$(subst "$(space)","$(comma)",$(strip $(foreach v,$(1),"$(call json_quote,$(v))"))))
metadata_json = \
'{ $(if $(IMAGE_METADATA),$(IMAGE_METADATA)$(comma)) \
"metadata_version": "1.0", \
"supported_devices":[$(call metadata_devices,$(1))], \
"version": { \
"dist": "$(call json_quote,$(VERSION_DIST))", \
"version": "$(call json_quote,$(VERSION_NUMBER))", \
"revision": "$(call json_quote,$(REVISION))", \
"board": "$(call json_quote,$(BOARD))" \
"target": "$(call json_quote,$(TARGETID))", \
"board": "$(call json_quote,$(if $(BOARD_NAME),$(BOARD_NAME),$(DEVICE_NAME)))" \
} \
}'

Expand Down
8 changes: 5 additions & 3 deletions include/image.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ param_get_default = $(firstword $(call param_get,$(1),$(2)) $(3))
param_mangle = $(subst $(space),_,$(strip $(1)))
param_unmangle = $(subst _,$(space),$(1))

mkfs_packages_id = $(shell echo $(sort $(1)) | mkhash md5 | head -c 8)
mkfs_packages_id = $(shell echo $(sort $(1)) | mkhash md5 | cut -b1-8)
mkfs_target_dir = $(if $(call param_get,pkg,$(1)),$(KDIR)/target-dir-$(call param_get,pkg,$(1)),$(TARGET_DIR))

KDIR=$(KERNEL_BUILD_DIR)
Expand All @@ -44,6 +44,7 @@ IMG_PREFIX_VERCODE:=$(if $(CONFIG_VERSION_CODE_FILENAMES),$(call sanitize,$(VERS
IMG_PREFIX:=$(VERSION_DIST_SANITIZED)-$(IMG_PREFIX_VERNUM)$(IMG_PREFIX_VERCODE)$(IMG_PREFIX_EXTRA)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
IMG_ROOTFS:=$(IMG_PREFIX)-rootfs
IMG_COMBINED:=$(IMG_PREFIX)-combined
IMG_PART_SIGNATURE:=$(shell echo $(SOURCE_DATE_EPOCH)$(LINUX_VERMAGIC) | mkhash md5 | cut -b1-8)

MKFS_DEVTABLE_OPT := -D $(INCLUDE_DIR)/device_table.txt

Expand Down Expand Up @@ -242,7 +243,7 @@ define Image/mkfs/squashfs
$(STAGING_DIR_HOST)/bin/mksquashfs4 $(call mkfs_target_dir,$(1)) $@ \
-nopad -noappend -root-owned \
-comp $(SQUASHFSCOMP) $(SQUASHFSOPT) \
-processors 16
-processors 1
endef

# $(1): board name
Expand Down Expand Up @@ -287,7 +288,7 @@ define Image/mkfs/ubifs
endef

define Image/mkfs/ext4
$(STAGING_DIR_HOST)/bin/make_ext4fs \
$(STAGING_DIR_HOST)/bin/make_ext4fs -L rootfs \
-l $(ROOTFS_PARTSIZE) -b $(CONFIG_TARGET_EXT4_BLOCKSIZE) \
$(if $(CONFIG_TARGET_EXT4_RESERVED_PCT),-m $(CONFIG_TARGET_EXT4_RESERVED_PCT)) \
$(if $(CONFIG_TARGET_EXT4_JOURNAL),,-J) \
Expand Down Expand Up @@ -597,6 +598,7 @@ define Device/Build/image
SUPPORTED_DEVICES="$(SUPPORTED_DEVICES)" \
$(TOPDIR)/scripts/json_add_image_info.py \
)

endef

define Device/Build/artifact
Expand Down
15 changes: 15 additions & 0 deletions package/kernel/linux/modules/other.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1230,3 +1230,18 @@ define KernelPackage/it87-wdt/description
endef

$(eval $(call KernelPackage,it87-wdt))


define KernelPackage/pinctrl-sx150x
SUBMENU:=$(OTHER_MENU)
TITLE:=Semtech SX150x-series I2C GPIO expanders
DEPENDS:= +kmod-i2c-core @!LINUX_4_9
KCONFIG:=CONFIG_PINCTRL_SX150X=y
AUTOLOAD:=$(call AutoLoad,40,pinctrl-sx150x)
endef

define KernelPackage/pinctrl-sx150x/description
This driver adds support for Semtech SX150x-series I2C GPIO expanders.
endef

$(eval $(call KernelPackage,pinctrl-sx150x))
26 changes: 26 additions & 0 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh


get_magic_word() {
dd if=$1 bs=4 count=1 2>/dev/null | od -A n -N 4 -t x1 | tr -d ' '
}

get_fs_type() {
local magic_word="$(get_magic_word "$1")"

case "$magic_word" in
"3118"*)
echo "ubifs"
;;
"68737173")
echo "squashfs"
;;
*)
echo "unknown"
;;
esac
}

round_up() {
echo "$(((($1 + ($2 - 1))/ $2) * $2))"
}
47 changes: 31 additions & 16 deletions scripts/ubinize-image.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
#!/bin/sh

. $TOPDIR/scripts/functions.sh

part=""
ubootenv=""
ubinize_param=""
kernel=""
rootfs=""
outfile=""
err=""

get_magic_word() {
dd if=$1 bs=2 count=1 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"'
}

is_ubifs() {
if [ "$( get_magic_word $1 )" = "3118" ]; then
echo "1"
fi
}
ubinize_seq=""

ubivol() {
volid=$1
Expand All @@ -31,7 +24,7 @@ ubivol() {
echo "vol_name=$name"
if [ "$image" ]; then
echo "image=$image"
[ -n "$size" ] && echo "vol_size=${size}MiB"
[ -n "$size" ] && echo "vol_size=${size}"
else
echo "vol_size=1MiB"
fi
Expand All @@ -42,7 +35,10 @@ ubivol() {

ubilayout() {
local vol_id=0
local root_is_ubifs="$( is_ubifs "$2" )"
local rootsize=
local autoresize=
local rootfs_type="$( get_fs_type "$2" )"

if [ "$1" = "ubootenv" ]; then
ubivol $vol_id ubootenv
vol_id=$(( $vol_id + 1 ))
Expand All @@ -62,16 +58,34 @@ ubilayout() {

size="$part"

ubivol $vol_id "$name" "$image" "" "$size"
ubivol $vol_id "$name" "$image" "" "${size}MiB"
vol_id=$(( $vol_id + 1 ))
done
if [ "$3" ]; then
ubivol $vol_id kernel "$3"
vol_id=$(( $vol_id + 1 ))
fi
ubivol $vol_id rootfs "$2" $root_is_ubifs

case "$rootfs_type" in
"ubifs")
autoresize=1
;;
"squashfs")
# squashfs uses 1k block size, ensure we do not
# violate that
rootsize="$( round_up "$( stat -c%s "$2" )" 1024 )"
;;
esac
ubivol $vol_id rootfs "$2" "$autoresize" "$rootsize"

vol_id=$(( $vol_id + 1 ))
[ "$root_is_ubifs" ] || ubivol $vol_id rootfs_data "" 1
[ "$rootfs_type" = "ubifs" ] || ubivol $vol_id rootfs_data "" 1
}

set_ubinize_seq() {
if [ -n "$SOURCE_DATE_EPOCH" ] ; then
ubinize_seq="-Q $SOURCE_DATE_EPOCH"
fi
}

while [ "$1" ]; do
Expand Down Expand Up @@ -130,8 +144,9 @@ if [ -z "$ubinizecfg" ]; then
fi
ubilayout "$ubootenv" "$rootfs" "$kernel" > "$ubinizecfg"

set_ubinize_seq
cat "$ubinizecfg"
ubinize -o "$outfile" $ubinize_param "$ubinizecfg"
ubinize $ubinize_seq -o "$outfile" $ubinize_param "$ubinizecfg"
err="$?"
[ ! -e "$outfile" ] && err=2
rm "$ubinizecfg"
Expand Down
Loading

0 comments on commit 7ea08e9

Please sign in to comment.