AnsweredAssumed Answered

Best practices for partitioning MTD

Question asked by halm on Mar 9, 2012
Latest reply on Mar 12, 2012 by Aaronwu

This is similar to http://ez.analog.com/thread/12095 ... but not quite.

 

I have nor flash and I've tried to lay out the partitions as follows:

static struct mtd_partition cm_partitions[] = {

        {       /* mtd0: 0x20000000 - 0x2003ffff */

                .name   = "bootloader(nor)",

                .size   = 0x40000,

                .offset = 0,

        }, {    /* mtd1: 0x20040000 - 0x2017ffff */

                .name   = "uclinux safe kernel(nor)",

                .size   = 0x140000,

                .offset = MTDPART_OFS_APPEND,

        }, {    /* mtd2: 0x20180000 - 0x201dffff */

                .name   = " safe linux filesystem(nor)",

                .size   = 0x60000,

                .offset = MTDPART_OFS_APPEND,

        }, {    /* mtd3: 0x201e0000 - 0x2035ffff */

                .name   = "uclinux kernel(nor)",

                .size   = 0x180000,

                .offset = MTDPART_OFS_APPEND,

        }, {    /* mtd4: 0x20360000              */

                .name   = "primary file system(nor)",

                .size   = MTDPART_SIZ_FULL,

                .offset = MTDPART_OFS_APPEND,

        }

};

 

The idea is that the safe kernel and it's filesystem would be read only, and booted to only in an emergency.  The last 2 partitions are for normal operation.

 

First of all, is this a reasonable expectation?

 

Next, I don't understand this:

bfin> tftp 0x1000000 rootfs.jffs2-safe

Using bfin_mac device

TFTP from server 10.1.2.56; our IP address is 10.1.2.24

Filename 'rootfs.jffs2-safe'.

Load address: 0x1000000

Loading: #################################################################

             #############################################################

done

Bytes transferred = 1835008 (1c0000 hex)

 

I've defined the partition to be 0x60000, and yet the transfer is 0x1c0000.   This messes up my offset calculations when copying to flash.

There's something going on here that I don't understand.

 

Depending on how I copy to flash (using the sizes I expect or the sizes I observer on download) I either fail unable to find a kernel image (in the former case) or something like this in the latter.

-----------------------

 

CPU:   ADSP bf516-0.2 (Detected Rev: 0.2) (parallel flash boot)

__ADSPBF516__ not defined

Board: iMix Dev Board

       Support: http://www.loudtechinc.com

gpio_cfi_flash_init()

Clock: VCO: 400 MHz, Core: 400 MHz, System: 100 MHz

RAM:   32 MiB

Flash: 32 MiB

In:    serial

Out:   serial

Err:   serial

KGDB:  [on serial] ready

Net:   bfin_mac

Hit any key to stop autoboot:  0

## Booting kernel from Legacy Image at 20040000 ...

   Image Name:   bf516-0.2-2.6.37-ADI-2011R1-pre

   Created:      2012-03-09   5:28:15 UTC

   Image Type:   Blackfin Linux Kernel Image (gzip compressed)

   Data Size:    1003947 Bytes = 980.4 KiB

   Load Address: 00001000

   Entry Point:  001b78a0

   Verifying Checksum ... OK

   Uncompressing Kernel Image ... OK

Starting Kernel at = 001b78a0

Linux version 2.6.37-ADI-2011R1-pre (halm@wdn-halm-linux) (gcc version 4.3.5 (AD

I-2010R1-RC4) ) #755 Thu Mar 8 21:28:14 PST 2012

register early platform devices

Board Memory: 32MB

Kernel Managed Memory: 32MB

Memory map:

  fixedcode = 0x00000400-0x00000490

  text      = 0x00001000-0x00142150

  rodata    = 0x00142150-0x001859d0

  bss       = 0x00186000-0x0019ab44

  data      = 0x0019ab44-0x001b0000

    stack   = 0x001ae000-0x001b0000

  init      = 0x001b0000-0x001ce000

  available = 0x001ce000-0x01f00000

  DMA Zone  = 0x01f00000-0x02000000

Hardware Trace Active and Enabled

Boot Mode: 1

Blackfin support (C) 2004-2010 Analog Devices, Inc.

Compiled for ADSP-BF516 Rev 0.2

Blackfin Linux support by http://blackfin.uclinux.org/

Processor Speed: 400 MHz core clock and 100 MHz System Clock

NOMPU: setting up cplb tables

Instruction Cache Enabled for CPU0

  External memory: cacheable in instruction cache

Data Cache Enabled for CPU0

  External memory: cacheable (write-back) in data cache

Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 7874

Kernel command line: root=/dev/mtdblock2 rw rootfstype=jffs2 clkin_hz=25000000 e

arlyprintk=serial,uart0,115200 console=ttyBF0,115200

PID hash table entries: 128 (order: -3, 512 bytes)

Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)

Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)

Memory available: 29568k/32768k RAM, (120k init code, 1284k kernel code, 440k da

ta, 1024k dma, 332k reserved)

NR_IRQS:159

Configuring Blackfin Priority Driven Interrupts

Console: colour dummy device 80x25

console [ttyBF0] enabled

Calibrating delay loop... 780.28 BogoMIPS (lpj=390144)

pid_max: default: 32768 minimum: 301

Mount-cache hash table entries: 512

Blackfin Scratchpad data SRAM: 4 KB

Blackfin L1 Data A SRAM: 16 KB (16 KB free)

Blackfin L1 Data B SRAM: 16 KB (16 KB free)

Blackfin L1 Instruction SRAM: 32 KB (26 KB free)

NET: Registered protocol family 16

Blackfin DMA Controller

iMix_init(): registering device resources

bio: create slab <bio-0> at 0

bfin-spi bfin-spi.0: Blackfin on-chip SPI Controller Driver, Version 1.0, regs_b

ase@ffc00500, dma channel@7

i2c-bfin-twi i2c-bfin-twi.0: Blackfin BF5xx on-chip I2C TWI Contoller, regs_base

@ffc01400

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 1024 (order: 1, 8192 bytes)

TCP bind hash table entries: 1024 (order: 0, 4096 bytes)

TCP: Hash tables configured (established 1024 bind 1024)

TCP reno registered

UDP hash table entries: 256 (order: 0, 4096 bytes)

UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)

NET: Registered protocol family 1

debug-mmrs: setting up Blackfin MMR debugfs

JFFS2 version 2.2. (NAND) (SUMMARY)  ▒© 2001-2006 Red Hat, Inc.

msgmni has been set to 57

io scheduler noop registered (default)

bfin-otp: initialized

bfin-uart: Blackfin serial driver

bfin-uart.0: ttyBF0 at MMIO 0xffc00400 (irq = 29) is a BFIN-UART

brd: module loaded

gpio-addr-flash: probing 16-bit flash bus

gpio-addr-flash: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x00

0001 Chip ID 0x002201

Amd/Fujitsu Extended Query Table at 0x0040

  Amd/Fujitsu Extended Query version 1.3.

number of CFI chips: 1

cmdlinepart partition parsing not available

RedBoot partition parsing not available

gpio-addr-flash: Using board partition definition

Creating 5 MTD partitions on "gpio-addr-flash":

0x000000000000-0x000000040000 : "bootloader(nor)"

0x000000040000-0x000000180000 : "uclinux mini kernel(nor)"

0x000000180000-0x0000001e0000 : "mini-linux filesystem(nor)"

0x0000001e0000-0x000000360000 : "uclinux kernel(nor)"

0x000000360000-0x000002000000 : "primary file system(nor)"

bfin_mii_bus: probed

bfin_mac: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1, mdc_

clk=2500000Hz(mdc_div=19)@sclk=100MHz)

bfin_mac bfin_mac.0: eth0: Blackfin on-chip Ethernet MAC driver, Version 1.1

rtc-bfin rtc-bfin: rtc core: registered rtc-bfin as rtc0

i2c /dev entries driver

bfin-wdt: initialized: timeout=20 sec (nowayout=0)

TCP cubic registered

NET: Registered protocol family 17

rtc-bfin rtc-bfin: setting system clock to 1970-01-01 00:00:00 UTC (0)

dma_alloc_init: dma_page @ 0x011b3000 - 256 pages at 0x01f00000

jffs2: Too few erase blocks (3)

List of all partitions:

1f00             256 mtdblock0  (driver?)

1f01            1280 mtdblock1  (driver?)

1f02             384 mtdblock2  (driver?)

1f03            1536 mtdblock3  (driver?)

1f04           29312 mtdblock4  (driver?)

No filesystem could mount root, tried:  jffs2

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)

Stack info:

SP: [0x0101bf24] ▒▒

Memory from 0x0101bf20 to 0101c000

0101bf20: 00000000 [0015357c] 001408ac  01084006  0015357c  0018b4bf  0018b4bf

0018b4bf

0101bf40: 0101bf6c  00191e40  001b0a60  01084006  01084000  001c4e1c  0101bf7c

00153488

0101bf60: 00000000  00000000  00000032  0101bf7c  0101bf7c  00008000  00000000

6e6b6e75

0101bf80: 2d6e776f  636f6c62  3133286b  0029322c  001b0b0e  00186068  00001f02

00000000

0101bfa0: 001b0c40  00186068  001c4dd4  00000000  00000000  00000000  00000000

001b01d2

0101bfc0: 001cb2fc  001cb2fc  00000000  00000000  001b01e6  001cb2fc  001cb2fc

00000000

0101bfe0: 00000000  00000000  00001576  00000000  00000000  00000000  ffffffff

00000006

Return addresses in stack:

Outcomes