-# Append header to a D-Link M32 Kernel 1 partition
-define Build/m32-recovery-header-kernel1
- echo -en "DLK6E6010001\x00\x00\xCF\x33" > "$@.header"
+# Append header to a D-Link M32/R32 Kernel 1 partition
+define Build/m32-r32-recovery-header-kernel1
+ $(eval header_start=$(word 1,$(1)))
+# create $@.header without the checksum
+ echo -en "$(header_start)\x00\x00" > "$@.header"
+# Calculate checksum over data area ($@) and append it to the header.
+# The checksum is the 2byte-sum over the whole data area.
+# Every overflow during the checksum calculation must increment the current checksum value by 1.
+ od -v -w2 -tu2 -An --endian little "$@" | awk '{ s+=$$1; } END { s%=65535; printf "%c%c",s%256,s/256; }' >> "$@.header"