aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2006-12-07 00:26:26 +0000
committerFelix Fietkau <nbd@openwrt.org>2006-12-07 00:26:26 +0000
commitcf52f51b85f1366f0124dda81e75b87badb13c50 (patch)
tree7a5a30118358684a78a0aa5432826a357249890c /target/linux
parenta1e679979795d56cae454b51145ed09e0b8a0a89 (diff)
downloadupstream-cf52f51b85f1366f0124dda81e75b87badb13c50.tar.gz
upstream-cf52f51b85f1366f0124dda81e75b87badb13c50.tar.bz2
upstream-cf52f51b85f1366f0124dda81e75b87badb13c50.zip
remove custom partition table hack, add ptgen utility for generating partition tables
SVN-Revision: 5704
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/rb532-2.6/config1
-rw-r--r--target/linux/rb532-2.6/image/Makefile16
-rwxr-xr-xtarget/linux/rb532-2.6/image/gen_image.sh17
-rw-r--r--target/linux/rb532-2.6/patches/130-custom_partitions.patch311
4 files changed, 18 insertions, 327 deletions
diff --git a/target/linux/rb532-2.6/config b/target/linux/rb532-2.6/config
index 2d2138261a..98474ad71a 100644
--- a/target/linux/rb532-2.6/config
+++ b/target/linux/rb532-2.6/config
@@ -1180,7 +1180,6 @@ CONFIG_CIFS=m
# Partition Types
#
CONFIG_PARTITION_ADVANCED=y
-CONFIG_OPENWRT_PARTITION=y
# CONFIG_ACORN_PARTITION is not set
# CONFIG_OSF_PARTITION is not set
# CONFIG_AMIGA_PARTITION is not set
diff --git a/target/linux/rb532-2.6/image/Makefile b/target/linux/rb532-2.6/image/Makefile
index 4907214469..1f3a88ba40 100644
--- a/target/linux/rb532-2.6/image/Makefile
+++ b/target/linux/rb532-2.6/image/Makefile
@@ -39,9 +39,6 @@ define Image/BuildKernel
$(CP) $(KDIR)/loader.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux
endef
-PARTITION1=\x80\x01\x01\x00\x27\x01\x20\x7b\x20\x00\x00\x00\xe0\x1e\x00\x00# 4 MB (kernel part)
-PARTITION2=\x00\x00\x01\x7c\x83\x01\xa0\x64\x00\x1f\x00\x00\x40\x7a\x00\x00# 16 MB (rootfs part)
-
define Image/cmdline/jffs2-64k
block2mtd.block2mtd=/dev/cfa2,65536 root=/dev/mtdblock0 rootfstype=jffs2
endef
@@ -56,18 +53,7 @@ endef
define Image/Build
$(STAGING_DIR)/bin/patch-cmdline $(LINUX_DIR)/vmlinux '$(strip $(call Image/cmdline/$(1))) '
- ( \
- echo -ne OWRT | dd bs=$$$$((0x1be)) conv=sync; \
- ( \
- echo -ne '$(strip $(PARTITION1))'; \
- echo -ne '$(strip $(PARTITION2))'; \
- ) | dd bs=$$$$((0x40)) conv=sync; \
- echo -ne '\x55\xaa'; \
- dd if=/dev/zero bs=$$$$((0x3e00)) conv=sync count=1; \
- dd if=$(LINUX_DIR)/vmlinux bs=$$$$((0x3dc000)) conv=sync; \
- cat $(KDIR)/root.$(1); \
- echo -ne '\xde\xad\xc0\xde'; \
- ) > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin
+ ./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin 4 $(LINUX_DIR)/vmlinux 16 $(KDIR)/root.$(1)
endef
$(eval $(call BuildImage))
diff --git a/target/linux/rb532-2.6/image/gen_image.sh b/target/linux/rb532-2.6/image/gen_image.sh
new file mode 100755
index 0000000000..e812859797
--- /dev/null
+++ b/target/linux/rb532-2.6/image/gen_image.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+OUTPUT="$1"
+KERNELSIZE="$2"
+KERNELIMAGE="$3"
+ROOTFSSIZE="$4"
+ROOTFSIMAGE="$5"
+
+rm -f "$OUTPUT"
+
+# create partition table
+set `ptgen -o "$OUTPUT" -h 16 -s 32 -t 0x27 -p ${KERNELSIZE}m -t 0x83 -p ${ROOTFSSIZE}m`
+
+KERNELOFFSET="$(($1 / 512))"
+ROOTFSOFFSET="$(($2 / 512))"
+
+dd if="$KERNELIMAGE" of="$OUTPUT" bs=512 conv=notrunc seek="$KERNELOFFSET"
+dd if="$ROOTFSIMAGE" of="$OUTPUT" bs=512 conv=notrunc seek="$ROOTFSOFFSET"
diff --git a/target/linux/rb532-2.6/patches/130-custom_partitions.patch b/target/linux/rb532-2.6/patches/130-custom_partitions.patch
deleted file mode 100644
index e4b332703a..0000000000
--- a/target/linux/rb532-2.6/patches/130-custom_partitions.patch
+++ /dev/null
@@ -1,311 +0,0 @@
-diff -urN linux.old/fs/partitions/check.c linux.dev/fs/partitions/check.c
---- linux.old/fs/partitions/check.c 2006-05-31 02:31:44.000000000 +0200
-+++ linux.dev/fs/partitions/check.c 2006-06-15 01:27:17.000000000 +0200
-@@ -29,6 +29,7 @@
- #include "ldm.h"
- #include "mac.h"
- #include "msdos.h"
-+#include "openwrt.h"
- #include "osf.h"
- #include "sgi.h"
- #include "sun.h"
-@@ -48,6 +49,9 @@
- * Probe partition formats with tables at disk address 0
- * that also have an ADFS boot block at 0xdc0.
- */
-+#ifdef CONFIG_OPENWRT_PARTITION
-+ openwrt_partition,
-+#endif
- #ifdef CONFIG_ACORN_PARTITION_ICS
- adfspart_check_ICS,
- #endif
-diff -urN linux.old/fs/partitions/Kconfig linux.dev/fs/partitions/Kconfig
---- linux.old/fs/partitions/Kconfig 2006-05-31 02:31:44.000000000 +0200
-+++ linux.dev/fs/partitions/Kconfig 2006-06-15 01:27:17.000000000 +0200
-@@ -14,6 +14,12 @@
-
- If unsure, say N.
-
-+config OPENWRT_PARTITION
-+ bool "OpenWrt partition support" if PARTITION_ADVANCED
-+ default y
-+ help
-+ Support the custom OpenWrt partition map
-+
- config ACORN_PARTITION
- bool "Acorn partition support" if PARTITION_ADVANCED
- default y if ARCH_ACORN
-diff -urN linux.old/fs/partitions/Makefile linux.dev/fs/partitions/Makefile
---- linux.old/fs/partitions/Makefile 2006-05-31 02:31:44.000000000 +0200
-+++ linux.dev/fs/partitions/Makefile 2006-06-15 01:27:17.000000000 +0200
-@@ -11,6 +11,7 @@
- obj-$(CONFIG_MAC_PARTITION) += mac.o
- obj-$(CONFIG_LDM_PARTITION) += ldm.o
- obj-$(CONFIG_MSDOS_PARTITION) += msdos.o
-+obj-$(CONFIG_OPENWRT_PARTITION) += openwrt.o
- obj-$(CONFIG_OSF_PARTITION) += osf.o
- obj-$(CONFIG_SGI_PARTITION) += sgi.o
- obj-$(CONFIG_SUN_PARTITION) += sun.o
-diff -urN linux.old/fs/partitions/openwrt.c linux.dev/fs/partitions/openwrt.c
---- linux.old/fs/partitions/openwrt.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux.dev/fs/partitions/openwrt.c 2006-06-15 01:27:17.000000000 +0200
-@@ -0,0 +1,249 @@
-+/*
-+ * fs/partitions/openwrt.c
-+ *
-+ * Code extracted from drivers/block/genhd.c
-+ * and fs/partitions/msdos.c
-+ *
-+ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
-+ * Copyright (C) 1991-1998 Linus Torvalds
-+ *
-+ * Thanks to Branko Lankester, lankeste@fwi.uva.nl, who found a bug
-+ * in the early extended-partition checks and added DM partitions
-+ *
-+ * Support for DiskManager v6.0x added by Mark Lord,
-+ * with information provided by OnTrack. This now works for linux fdisk
-+ * and LILO, as well as loadlin and bootln. Note that disks other than
-+ * /dev/hda *must* have a "DOS" type 0x51 partition in the first slot (hda1).
-+ *
-+ * More flexible handling of extended partitions - aeb, 950831
-+ *
-+ * Check partition table on IDE disks for common CHS translations
-+ *
-+ * Re-organised Feb 1998 Russell King
-+ */
-+
-+#include <linux/config.h>
-+
-+#include "check.h"
-+#include "openwrt.h"
-+
-+/*
-+ * Many architectures don't like unaligned accesses, while
-+ * the nr_sects and start_sect partition table entries are
-+ * at a 2 (mod 4) address.
-+ */
-+#include <asm/unaligned.h>
-+
-+#define SYS_IND(p) (get_unaligned(&p->sys_ind))
-+#define NR_SECTS(p) ({ __typeof__(p->nr_sects) __a = \
-+ get_unaligned(&p->nr_sects); \
-+ le32_to_cpu(__a); \
-+ })
-+
-+#define START_SECT(p) ({ __typeof__(p->start_sect) __a = \
-+ get_unaligned(&p->start_sect); \
-+ le32_to_cpu(__a); \
-+ })
-+
-+static inline int is_extended_partition(struct partition *p)
-+{
-+ return (SYS_IND(p) == DOS_EXTENDED_PARTITION ||
-+ SYS_IND(p) == WIN98_EXTENDED_PARTITION ||
-+ SYS_IND(p) == LINUX_EXTENDED_PARTITION);
-+}
-+
-+#define MSDOS_LABEL_MAGIC1 0x55
-+#define MSDOS_LABEL_MAGIC2 0xAA
-+
-+static inline int
-+msdos_magic_present(unsigned char *p)
-+{
-+ return (p[0] == MSDOS_LABEL_MAGIC1 && p[1] == MSDOS_LABEL_MAGIC2);
-+}
-+
-+static inline int
-+openwrt_magic_present(unsigned char *p)
-+{
-+ return (p[0] == 'O' &&
-+ p[1] == 'W' &&
-+ p[2] == 'R' &&
-+ p[3] == 'T');
-+}
-+
-+/*
-+ * Create devices for each logical partition in an extended partition.
-+ * The logical partitions form a linked list, with each entry being
-+ * a partition table with two entries. The first entry
-+ * is the real data partition (with a start relative to the partition
-+ * table start). The second is a pointer to the next logical partition
-+ * (with a start relative to the entire extended partition).
-+ * We do not create a Linux partition for the partition tables, but
-+ * only for the actual data partitions.
-+ */
-+
-+static void
-+parse_extended(struct parsed_partitions *state, struct block_device *bdev,
-+ u32 first_sector, u32 first_size)
-+{
-+ struct partition *p;
-+ Sector sect;
-+ unsigned char *data;
-+ u32 this_sector, this_size;
-+ int sector_size = bdev_hardsect_size(bdev) / 512;
-+ int loopct = 0; /* number of links followed
-+ without finding a data partition */
-+ int i;
-+
-+ this_sector = first_sector;
-+ this_size = first_size;
-+
-+ while (1) {
-+ if (++loopct > 100)
-+ return;
-+ if (state->next == state->limit)
-+ return;
-+ data = read_dev_sector(bdev, this_sector, &sect);
-+ if (!data)
-+ return;
-+
-+ if (!msdos_magic_present(data + 510))
-+ goto done;
-+
-+ p = (struct partition *) (data + 0x1be);
-+
-+ /*
-+ * Usually, the first entry is the real data partition,
-+ * the 2nd entry is the next extended partition, or empty,
-+ * and the 3rd and 4th entries are unused.
-+ * However, DRDOS sometimes has the extended partition as
-+ * the first entry (when the data partition is empty),
-+ * and OS/2 seems to use all four entries.
-+ */
-+
-+ /*
-+ * First process the data partition(s)
-+ */
-+ for (i=0; i<4; i++, p++) {
-+ u32 offs, size, next;
-+ if (!NR_SECTS(p) || is_extended_partition(p))
-+ continue;
-+
-+ /* Check the 3rd and 4th entries -
-+ these sometimes contain random garbage */
-+ offs = START_SECT(p)*sector_size;
-+ size = NR_SECTS(p)*sector_size;
-+ next = this_sector + offs;
-+ if (i >= 2) {
-+ if (offs + size > this_size)
-+ continue;
-+ if (next < first_sector)
-+ continue;
-+ if (next + size > first_sector + first_size)
-+ continue;
-+ }
-+
-+ put_partition(state, state->next, next, size);
-+ if (SYS_IND(p) == LINUX_RAID_PARTITION)
-+ state->parts[state->next].flags = 1;
-+ loopct = 0;
-+ if (++state->next == state->limit)
-+ goto done;
-+ }
-+ /*
-+ * Next, process the (first) extended partition, if present.
-+ * (So far, there seems to be no reason to make
-+ * parse_extended() recursive and allow a tree
-+ * of extended partitions.)
-+ * It should be a link to the next logical partition.
-+ */
-+ p -= 4;
-+ for (i=0; i<4; i++, p++)
-+ if (NR_SECTS(p) && is_extended_partition(p))
-+ break;
-+ if (i == 4)
-+ goto done; /* nothing left to do */
-+
-+ this_sector = first_sector + START_SECT(p) * sector_size;
-+ this_size = NR_SECTS(p) * sector_size;
-+ put_dev_sector(sect);
-+ }
-+done:
-+ put_dev_sector(sect);
-+}
-+
-+
-+int openwrt_partition(struct parsed_partitions *state, struct block_device *bdev)
-+{
-+ int sector_size = bdev_hardsect_size(bdev) / 512;
-+ Sector sect;
-+ unsigned char *data;
-+ struct partition *p;
-+ int slot;
-+ u32 last_block = 0;
-+ u32 size = 0;
-+ int firstfree = 5;
-+
-+ data = read_dev_sector(bdev, 0, &sect);
-+ if (!data)
-+ return -1;
-+ if (!openwrt_magic_present(data)) {
-+ printk("No OpenWrt partition table detected\n");
-+ put_dev_sector(sect);
-+ return 0;
-+ }
-+
-+ /*
-+ * Now that the 55aa signature is present, this is probably
-+ * either the boot sector of a FAT filesystem or a DOS-type
-+ * partition table. Reject this in case the boot indicator
-+ * is not 0 or 0x80.
-+ */
-+ p = (struct partition *) (data + 0x1be);
-+ for (slot = 1; slot <= 4; slot++, p++) {
-+ if (p->boot_ind != 0 && p->boot_ind != 0x80) {
-+ put_dev_sector(sect);
-+ return 0;
-+ }
-+ }
-+
-+ p = (struct partition *) (data + 0x1be);
-+
-+ /*
-+ * Look for partitions in two passes:
-+ * First find the primary and DOS-type extended partitions.
-+ */
-+
-+ state->next = 6;
-+ for (slot = 1 ; slot <= 4 ; slot++, p++) {
-+ u32 start = START_SECT(p)*sector_size;
-+ size = NR_SECTS(p)*sector_size;
-+ if (!size) {
-+ if (firstfree > slot)
-+ firstfree = slot;
-+
-+ continue;
-+ }
-+ if (is_extended_partition(p)) {
-+ /* prevent someone doing mkfs or mkswap on an
-+ extended partition, but leave room for LILO */
-+ last_block = start + size;
-+ put_partition(state, slot, start, size == 1 ? 1 : 2);
-+ printk(" <");
-+ parse_extended(state, bdev, start, size);
-+ printk(" >");
-+ continue;
-+ }
-+ if ((start + size) > get_capacity(bdev->bd_disk))
-+ size = get_capacity(bdev->bd_disk) - start;
-+ last_block = start + size;
-+ put_partition(state, slot, start, size);
-+ }
-+ if (last_block + 1024 < (size = get_capacity(bdev->bd_disk)))
-+ put_partition(state, firstfree, last_block, size - last_block);
-+
-+ printk("\n");
-+
-+ put_dev_sector(sect);
-+ return 1;
-+}
-+
-diff -urN linux.old/fs/partitions/openwrt.h linux.dev/fs/partitions/openwrt.h
---- linux.old/fs/partitions/openwrt.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux.dev/fs/partitions/openwrt.h 2006-06-15 01:27:17.000000000 +0200
-@@ -0,0 +1,6 @@
-+/*
-+ * fs/partitions/openwrt.h
-+ */
-+
-+int openwrt_partition(struct parsed_partitions *state, struct block_device *bdev);
-+