Commit 807f5672 authored by Alessandro Rubini's avatar Alessandro Rubini

partitions: compatible change, and update docs

This changes partitions, mainly adding a kernel-visible mapping of
what we ha in dataflash.  NAND changes are compatible, as only empty
space is used differently.

This also includes a new barebox.bin, that you can just write
to /dev/mtd3 after booting the new kernel.

Documentation is updated to reflect these partitions, but there also
old leftovers that are fixed in this same commit.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 8f04f8e8
No preview for this file type
......@@ -35,7 +35,7 @@
@setchapternewpage off
@set update-month May 2014
@set update-month June 2014
@c the release name below is substituted at build time
@set release __RELEASE_GIT_ID__
......@@ -566,7 +566,7 @@ Finally, the kernel should also load the proper device driver, and you
are expected to see @code{/dev/ttyACM0} or equivalent in your system.
This is the device used for flashing.
If it is not the case, this mean that the button used to disable the dataflash
If it is not the case, this means that the button used to disable the dataflash
and enter @emph{"Flashing mode"} is not working. You should contact support.
@c =============================================================================
......@@ -1104,21 +1104,23 @@ the bug, or to the newer @i{barebox} that obsoletes @i{at91boot}.
@section The Boot Loader
The switch uses @i{barebox} as a boot loader. We are running version
2012-05, with a few local patches and the chosen configuration
2014-04, with a few local patches and the chosen configuration
file. Note that we are piggy-backing on the Ronetix PM9G45 board, out
of laziness.
The patches are part of this package in @i{patches/barebox/v2012.05/} and
The patches are part of this package in @i{patches/barebox/v2014.04/} and
the set is made up of the following ones:
@smallexample
0001-sam945-include-mtd-nand.h-in-device-file.patch
0002-arm-change-prompt-for-pm9263-wrs-piggy-backs-on-that.patch
0003-nand-wrs-our-nand-is-16-bit-connected-fix-accordingl.patch
0004-add-DHCP-retries-by-tom.patch
0005-gpio-add-function-to-check-them.patch
0006-startup-load-default-environment-when-loading-env-fa.patch
0007-wrs-on-pm9g45-change-nand-setup.patch
0004-gpio-add-function-to-check-them.patch
0005-wrs-on-pm9g45-change-nand-setup.patch
0006-wrs-on-pm9g45-add-dataflash-initialization.patch
0007-barebox-add-MAC-addresses-to-environment.patch
0008-wrs-on-pm9g45-force-memory-to-64MB.patch
0009-pm9g45-init-for-wrs-move-environment-for-the-UBI-mov.patch
@end smallexample
If you build using a local @i{git} repository, we suggest to use
......@@ -1130,14 +1132,14 @@ environment, and its own configuration and scripts live in a small
filesystem. To ease modification of such configuration and boot steps
the build script copies over the configuration instead of patching it
in the sources. You can thus edit the files you find in
@file{patches/barebox/v2012.05/env} and rebuild your customized bootloader.
@file{patches/barebox/v2014.04/env} and rebuild your customized bootloader.
The script that is executed at boot time is @file{env/bin/init} and as
you see it calls the other ones. The menus included in the shipped
configuration are described in @ref{Booting with Barebox}.
Building @i{barebox} relies on a @i{Kconfig} setup, and the
configuration file we use is
@file{patches/barebox/v2012.05/@-wrs3_defconfig}. Again, this is copied over and
@file{patches/barebox/v2014.04/@-wrs3_defconfig}. Again, this is copied over and
not patched in (see the simple @file{build/scripts/@-wrs_build_barebox}
for details).
......@@ -1188,8 +1190,12 @@ and are currently the following ones:
0002-initramfs-stop-after-one-cpio-archive.patch
0003-at91-NR_IRQS-increase-by-64-to-fit-custom-muxes.patch
0004-irq-export-symbols-for-external-irq-controller.patch
0005-fix-nand-parition-layout-and-usb-vbus.patch
0006-fiq-support.patch
0005-Change-Vbus-pin.patch
0006-arm-fiq-allow-modules-to-exploit-the-fiq-mechanism.patch
0007-mtd-nand-sam9g45-can-hwecc-like-9263.patch
0008-wrs3-use-correct-nand-partitioning.patch
0009-at91-udc-force-full-speed.patch
0010-sam9m10g45ek-for-wrs-new-partitioning.patch
@end example
The configuration we use to build the kernel is not a patch but a plain
......@@ -1227,7 +1233,7 @@ Currently, the package includes the following modules:
@itemize @bullet
@item @i{wr_vic.ko}: the interrupt controller for in-FPGA devices.
@item @i{wr-nic.ko}: the network ``card'' driver for WR ports.
@item @i{at91_softpwm}: a tool that generates a PWM signal for the fan.
@item @i{at91_softpwm.ko}: a driver that generates a PWM signal for the fan.
@item @i{wr_rtu.ko}: the routing-table interface between the
switching core and the associated user-space daemon.
@end itemize
......@@ -1450,33 +1456,35 @@ it is the result of our own history of development and there are
no problems with this ``strange'' split up of space:
@example
0x0000.0000 - 0x0004.0000 Empty (space for a barebox)
0x0004.0000 - 0x0008.0000 Barebox environment
0x0008.0000 - 0x0010.0000 Empty
0x0000.0000 - 0x0010.0000 Barebox Environment
0x0010.0000 - 0x0090.0000 Kernel (plenty of space)
0x0090.0000 - 0x0400.0000 Empty
0x0400.0000 - 0x0c00.0000 Filesystem space, jffs2
0x0c00.0000 - 0x2000.0000 Available
@end example
When you boot Linux, the three empty areas are not visible, while
the last area is accessible. This is the content of @file{/proc/mtd}
When you boot Linux, the two empty areas are not visible, while
the last area is accessible. Also, the @i{dataflash} partitioning
is visible (thus, you can replace @t{barebox.bin} by just writing
it to the right device file). This is the content of @file{/proc/mtd}
after boot:
@example
dev: size erasesize name
mtd0: 00800000 00020000 "Kernel"
mtd1: 08000000 00020000 "Filesystem"
mtd2: 00040000 00020000 "Barebox Environment"
mtd3: 14000000 00020000 "Available"
mtd4: 00840000 00000420 "spi0.0-AT45DB642x"
mtd0: 00100000 00020000 "Barebox-environment-backup"
mtd1: 00800000 00020000 "Kernel"
mtd2: 08000000 00020000 "Filesystem"
mtd3: 14000000 00020000 "Available-nand"
mtd4: 00008400 00000420 "at91boot"
mtd5: 00084000 00000420 "Barebox"
mtd6: 00008400 00000420 "Barebox-Environment"
mtd7: 007ab800 00000420 "Available-dataflash"
@end example
If you are customizing the switch, you may use the
@file{flash_erase} and @file{cat} to replace individual parts of
the system, like the kernel, or erase the @i{barebox} configuration to
restore the factory defaults. Note however that you shouldn't
modify the @i{dataflash} device (@code{/dev/mtd4}) unless you really
modify the @i{dataflash} device (@code{/dev/mtd4-7}) unless you really
know what you are doing (for example, the following chapter changes
it by using magic offsets in the commands).
......@@ -1639,7 +1647,7 @@ The first 4 lines are printed by @i{at91bootstrap}, the rest by @i{barebox}.
++++++++++++++++
Loading image done.
barebox 2014.04.0 #1 Fri May 2 18:32:51 CEST 2014
barebox 2014.04.0 #1 Thu Jun 19 12:27:42 CEST 2014
Board: White Rabbit Switch
AT91: Detected soc type: at91sam9g45
......@@ -1672,21 +1680,27 @@ at @code{/proc/mtd}:
@c FIXME: mtd layout
@example
# cat /proc/mtd
dev: size erasesize name
mtd0: 00800000 00020000 "Kernel"
mtd1: 08000000 00020000 "Filesystem"
mtd2: 00040000 00020000 "Barebox Environment"
mtd3: 14000000 00020000 "Available"
mtd4: 00840000 00000420 "spi0.0-AT45DB642x"
mtd0: 00100000 00020000 "Barebox-environment-backup"
mtd1: 00800000 00020000 "Kernel"
mtd2: 08000000 00020000 "Filesystem"
mtd3: 14000000 00020000 "Available-nand"
mtd4: 00008400 00000420 "at91boot"
mtd5: 00084000 00000420 "Barebox"
mtd6: 00008400 00000420 "Barebox-Environment"
mtd7: 007ab800 00000420 "Available-dataflash"
@end example
Here above, the DataFlash is @i{/dev/mtd4}, whereas the former partitions
refer to NAND memory. You should then write @i{at91boot} to offset 0
of the DataFlash and @i{barebox} to offset 0x8400 (33792):
Here above, the DataFlash is @i{/dev/mtd4} and later,
whereas the former partitions
refer to NAND memory. You should then write @i{at91boot} to @t{/dev/mtd4}
and @i{barebox} to @t{/dev/mtd5}, but the devices are not created
by default:
@example
mknod /dev/mtd4 c 90 8
cat at91bootstrap.bin > /dev/mtd4
dd bs=33792 seek=1 if=barebox.bin of=/dev/mtd4
mknod /dev/mtd5 c 90 10
cat barebox.bin > /dev/mtd5
@end example
Now you can detach the debugger, press reset and see @i{barebox} starting
......
From 685747bfa8bc8a41f5e47077a67c0db18b7561c7 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Thu, 19 Jun 2014 11:34:24 +0200
Subject: [PATCH 9/9] pm9g45/init (for wrs): move environment for the UBI move
This moves environment to the first meg of nand so we can ubify the
rest of the nand memory. Also, prepare for dataflash placement, even
if it doesn't work yet.
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
---
arch/arm/boards/pm9g45/init.c | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/arch/arm/boards/pm9g45/init.c b/arch/arm/boards/pm9g45/init.c
index 1f7cc1c..d4cea02 100644
--- a/arch/arm/boards/pm9g45/init.c
+++ b/arch/arm/boards/pm9g45/init.c
@@ -189,9 +189,29 @@ static int pm9g45_devices_init(void)
pm9g45_add_device_eth();
pm9g45_add_device_usbh();
- //device, offset, size, flag, name
- devfs_add_partition("nand0", 0x40000, 0x40000, DEVFS_PARTITION_FIXED, "env_raw");
- dev_add_bb_dev("env_raw", "env0");
+ if (0) {
+ /*
+ * This is where we want to go, but dataflash access is
+ * currently not working, so we can't saveenv in there
+ */
+ devfs_add_partition("dataflash0", /* after at91boot + bbox */
+ 0x8400 + 0x84000, 0x8400,
+ DEVFS_PARTITION_FIXED, "env0");
+ } else {
+ /*
+ * This is similar to the previous setup, but we'd better
+ * use the first meg for the environment. This gives us
+ * ample space for bad blocks, and a known place (0) with
+ * an easy-to-remember size (1M). Previous partitioning left
+ * the first meg unused, so this is compatible with the
+ * v3.x layout of the partitions
+ */
+ devfs_add_partition("nand0", /* 1M at the begginning */
+ 0, 1<<20,
+ DEVFS_PARTITION_FIXED, "env_raw");
+ /* This is the bad-block-aware mirror of env_raw */
+ dev_add_bb_dev("env_raw", "env0");
+ }
armlinux_set_architecture(MACH_TYPE_PM9G45);
--
1.7.7.2
From 76e58431485ad6b9d78eb0eec449c723dec1ecff Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Thu, 19 Jun 2014 11:42:41 +0200
Subject: [PATCH 10/10] sam9m10g45ek (for wrs): new partitioning
This moves environment to the first meg of nand so we can later ubify
the rest of the nand memory. Such placement if compatible with
current partitioning, which is unchanged.
Also, it prepare partitions in the dataflash, to reflect actual
placement of the stuff and ease replacing barebox or at91boot from a
running system (useful for me and Benoit for release work, nobody else
is expected to change dataflash).
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
---
arch/arm/mach-at91/board-sam9m10g45ek.c | 46 +++++++++++++++++++++++++-----
1 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c
index d40aa3c..afc6418 100644
--- a/arch/arm/mach-at91/board-sam9m10g45ek.c
+++ b/arch/arm/mach-at91/board-sam9m10g45ek.c
@@ -25,6 +25,7 @@
#include <linux/leds.h>
#include <linux/clk.h>
#include <linux/atmel-mci.h>
+#include <linux/spi/flash.h>
#include <mach/hardware.h>
#include <video/atmel_lcdc.h>
@@ -88,12 +89,42 @@ static struct usba_platform_data __initdata ek_usba_udc_data = {
/*
* SPI devices.
*/
+static struct mtd_partition wrs_df_parts[] = {
+ {
+ .name = "at91boot",
+ .offset = 0,
+ .size = 0x8400,
+ },
+ {
+ .name = "Barebox",
+ .offset = MTDPART_OFS_APPEND,
+ .size = 0x84000,
+ },
+ {
+ .name = "Barebox-Environment",
+ .offset = MTDPART_OFS_APPEND,
+ .size = 0x8400,
+ },
+ {
+ .name = "Available-dataflash",
+ .offset = MTDPART_OFS_APPEND,
+ .size = MTDPART_SIZ_FULL,
+ },
+};
+
+static struct flash_platform_data wrs_df_pdata = {
+ .name = "wrs-dataflash",
+ .parts = wrs_df_parts,
+ .nr_parts = ARRAY_SIZE(wrs_df_parts),
+};
+
static struct spi_board_info ek_spi_devices[] = {
{ /* DataFlash chip */
.modalias = "mtd_dataflash",
.chip_select = 0,
.max_speed_hz = 15 * 1000 * 1000,
.bus_num = 0,
+ .platform_data = &wrs_df_pdata,
},
};
@@ -131,6 +162,11 @@ static struct at91_eth_data __initdata ek_macb_data = {
*/
static struct mtd_partition __initdata ek_nand_partition[] = {
{
+ .name = "Barebox-environment-backup",
+ .offset = 0,
+ .size = SZ_1M,
+ },
+ {
.name = "Kernel",
.offset = 1 << 20,
.size = SZ_8M,
@@ -141,14 +177,8 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
.size = SZ_128M,
},
{
- .name = "Barebox Environment",
- .offset = 256 << 10,
- .size = SZ_256K,
- },
- /* This is actuallywas MTDPART_OFS_APPEND over the filesystem */
- {
- .name = "Available",
- .offset = (128+64) << 20,
+ .name = "Available-nand",
+ .offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
},
};
--
1.7.7.2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment