understanding/adjusting the partitions on a firefly

797 views
Skip to first unread message

Trevor Woerner

unread,
Jul 1, 2015, 3:37:56 PM7/1/15
to linux-r...@googlegroups.com
Hi,

If I use rkflashtool[1] I can dump the parameters from my firefly:

# ./rkflashtool p
rkflashtool: info: rkflashtool v5.2
rkflashtool: info: Detected RK3288...
rkflashtool: info: interface claimed
rkflashtool: info: reading parameters at offset 0x00000000
rkflashtool: info: size: 0x00000230
FIRMWARE_VER:4.4.2
MACHINE_MODEL:rk30sdk
MACHINE_ID:007
MANUFACTURER:RK30SDK
MAGIC: 0x5041524B
ATAG: 0x60000800
MACHINE: 3066
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
#KERNEL_IMG: 0x62008000
#FDT_NAME: rk-kernel.dtb
#RECOVER_KEY: 1,1,0,20,0
CMDLINE:console=tty0 console=ttyS2 earlyprintk
root=/dev/block/mtd/by-name/linuxroot rw rootfstype=ext4 init=/sbin/init
initrd=0x62000000,0x00800000
mtdparts=rk29xxnand:0x00008000@0x00002000(resource),0x00008000@0x0000A000(boot),0x00002000@0x00012000(misc),0x0001a000@0x00014000(backup),-@0x0002e000(linuxroot)


My understanding is that the firefly has some eMMC memory on it[2] which
is partitioned. One of these partitions is named "parameter" and that's
what the "rkflashtool p" command is dumping out in the above output? If
I run "rkflashtool P" the command will read values from stdin and write
the "parameters" partition with whatever it reads (most people simply
redirect the contents of a file)?

Why are some of the lines commented out? Do I need to provide them to
"rdkflashtool P" if they're commented out?

Is it possible to repartition and/or rename the partitions by simply
changing the values from the above output and writing them back using
"rkflashtool P"? For example, the RK3288 has a first stage bootloader in
ROM which looks for a runs a second stage bootloader from the "boot"
partition(?). If I changed the name of the "boot" partition to "myboot",
would my device not be able to enter "loader mode"?

E.g.
# rkflashtool P
FIRMWARE_VER:4.4.2
MACHINE_MODEL:rk30sdk
MACHINE_ID:007
MANUFACTURER:RK30SDK
MAGIC: 0x5041524B
ATAG: 0x60000800
MACHINE: 3066
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
CMDLINE:console=tty0 console=ttyS2 earlyprintk
root=/dev/block/mtd/by-name/linuxroot rw rootfstype=ext4 init=/sbin/init
initrd=0x62000000,0x00800000
mtdparts=rk29xxnand:0x00008000@0x00002000(resource),0x00008000@0x0000A000(myboot),0x00002000@0x00012000(misc),0x0001a000@0x00014000(backup),-@0x0002e000(linuxroot)

Best regards,
Trevor



[1] https://github.com/linux-rockchip/rkflashtool.git
[2] https://en.wikipedia.org/wiki/MultiMediaCard#eMMC

Naoki FUKAUMI

unread,
Jul 1, 2015, 8:47:52 PM7/1/15
to Trevor Woerner, linux-r...@googlegroups.com
Hi,

On Thu, Jul 2, 2015 at 4:37 AM, Trevor Woerner <twoe...@gmail.com> wrote:
> My understanding is that the firefly has some eMMC memory on it[2] which
> is partitioned.

there is no _physical_ partition on eMMC on Firefly.

> One of these partitions is named "parameter" and that's
> what the "rkflashtool p" command is dumping out in the above output?

one of _logical_(=defined by software) partition is named "parameter"
and, yes, "rkflashtool p" dumps it.

> If
> I run "rkflashtool P" the command will read values from stdin and write
> the "parameters" partition with whatever it reads (most people simply
> redirect the contents of a file)?

yes.

> Why are some of the lines commented out?

no idea, we are not firefly team.

> Do I need to provide them to
> "rdkflashtool P" if they're commented out?

loader ignores commented out lines. you can ignore them too.

> Is it possible to repartition and/or rename the partitions by simply
> changing the values from the above output and writing them back using
> "rkflashtool P"?

yes.

> For example, the RK3288 has a first stage bootloader in
> ROM

correct, but generally it will not be called as "first stage" "(boot)loader".
it's called as "mask rom" in most cases.

> which looks for a runs a second stage bootloader from the "boot"
> partition(?).

incorrect.

please read my explanation again.

http://irclog.whitequark.org/linux-rockchip/2015-07-01#13278265
http://irclog.whitequark.org/linux-rockchip/2015-07-01#13278386
http://irclog.whitequark.org/linux-rockchip/2015-07-01#13278319
http://irclog.whitequark.org/linux-rockchip/2015-07-01#13278365
http://irclog.whitequark.org/linux-rockchip/2015-07-01#13278380
http://irclog.whitequark.org/linux-rockchip/2015-07-01#13278396
http://irclog.whitequark.org/linux-rockchip/2015-07-01#13278412
http://irclog.whitequark.org/linux-rockchip/2015-07-01#13278483
http://irclog.whitequark.org/linux-rockchip/2015-07-01#13278488
http://irclog.whitequark.org/linux-rockchip/2015-07-01#13278568

my explanation was about official rockchip implementation. it will not
be true on other implementations, e.g. some implementation may not
support "logical partition defined by parameter".

> If I changed the name of the "boot" partition to "myboot",
> would my device not be able to enter "loader mode"?

as I explained, loader is not in "boot" partition.

Regards,

Trevor Woerner

unread,
Jul 2, 2015, 12:17:22 PM7/2/15
to Naoki FUKAUMI, linux-r...@googlegroups.com
Hello,

On 07/01/15 20:47, Naoki FUKAUMI wrote:
> Hi,
>
> On Thu, Jul 2, 2015 at 4:37 AM, Trevor Woerner <twoe...@gmail.com> wrote:
>> My understanding is that the firefly has some eMMC memory on it[2] which
>> is partitioned.
> there is no _physical_ partition on eMMC on Firefly.

Oh. I see you have perfectly anticipated why this is confusing me :-)

I can write whatever I want to almost where ever I want in the eMMC and
it doesn't become a "partition" until I update the "parameters" area. By
using the "rkflashtool P" option, I'm not actually partitioning the eMMC
the way one would, for example, with a spinning disk, I'm just giving a
region of eMMC a name so that the bootloader(s), kernel, tools, etc can
find things based on names (instead of hard-coding addresses...
although, as you mentioned, some initial addresses need to be
hard-coded, e.g. sector 64 containing the "ID Block").

So, theoretically, I could load two different kernels and two different
root filesystems into the eMMC and switch between them simply by
updating the address values in the "parameters" area and rebooting. And
when one set is active, they won't know anything about the other set
(provided I haven't defined the other set in the parameters area).

The "parameters" area only defines "partitions" by providing a valid
cmdline to the Linux kernel (i.e. CMDLINE:...mtdparts=<partition
definitions>). That means that the Linux kernel (obviously), the tools
(such as rkflashtool), and the mask ROM code must all be able to parse
this same kernel CMDLINE correctly. So if ever the format of the Linux
kernel's mtdparts cmdline parameter changed in the future, it would mess
up anyone wanting to run new kernels on older chips? (because there
wouldn't be any way to update the code in the mask ROMs to deal with a
new format)

Best regards,
Trevor

Trevor Woerner

unread,
Jul 2, 2015, 12:25:32 PM7/2/15
to Naoki FUKAUMI, linux-r...@googlegroups.com
Hi,

On 07/01/15 20:47, Naoki FUKAUMI wrote:
>> which looks for a runs a second stage bootloader from the "boot"
>> partition(?).
> incorrect.
>
> please read my explanation again.
>
> as I explained, loader is not in "boot" partition.

Ah yes, sorry. My brain must have gone off to bed early when I wrote
that ;-)

The mask ROM looks in the "ID Block" (sector 64) for the locations of
the DRAM init code (usually sector 68) and the RKLoader.bin code
(usually sector 92). The RKLoader.bin implements the "loader mode".

Out of curiosity, when I was unpacking those images (the android and
ubuntu images from the firefly website) with the various tools, I did
find a RKLoader.bin (which, I believe implements the loader code you
described the other day on IRC) but the unpacking never produced a "DRAM
init" chunk. Any idea why there doesn't appear to be a "DRAM init" code
section in those images?

Best regards,
Trevor

Naoki FUKAUMI

unread,
Jul 2, 2015, 7:09:38 PM7/2/15
to Trevor Woerner, linux-r...@googlegroups.com
Hi,

On Fri, Jul 3, 2015 at 1:17 AM, Trevor Woerner <twoe...@gmail.com> wrote:
> The "parameters" area only defines "partitions" by providing a valid
> cmdline to the Linux kernel (i.e. CMDLINE:...mtdparts=<partition
> definitions>). That means that the Linux kernel (obviously), the tools
> (such as rkflashtool), and the mask ROM code must all be able to parse
> this same kernel CMDLINE correctly.

mask rom doesn't load(use) parameter. "parameter" method is
implemented in only Rockchip loader and Rockchip kernel.

upstream U-Boot, mainline Linux, and Barebox is good example which
don't use "parameter" (and partition information in it).

> So if ever the format of the Linux
> kernel's mtdparts cmdline parameter changed in the future, it would mess
> up anyone wanting to run new kernels on older chips? (because there
> wouldn't be any way to update the code in the mask ROMs to deal with a
> new format)

sorry, I couldn't understand this question... maybe "mask rom doesn't
use parameter" might be answer?

Regards,

Naoki FUKAUMI

unread,
Jul 2, 2015, 7:15:54 PM7/2/15
to Trevor Woerner, linux-r...@googlegroups.com
Hi,

On Fri, Jul 3, 2015 at 1:25 AM, Trevor Woerner <twoe...@gmail.com> wrote:
> The mask ROM looks in the "ID Block" (sector 64) for the locations of
> the DRAM init code (usually sector 68) and the RKLoader.bin code
> (usually sector 92). The RKLoader.bin implements the "loader mode".

RKLoader.bin(name might be vary) has 2 sets of 2 kind of code. 1 set
for USB booting, another set for flash storage.

- for USB
a. DRAM init code
b. loader (for USB booting)
- for flash storage (NAND/eMMC/SD)
A. DRAM init code
B. loader

you can find some detail in Rockchip U-Boot
(https://github.com/linux-rockchip/u-boot-rockchip or u-boot directory
in SDK), Simon's upstream U-Boot. and https://github.com/apxii

> Out of curiosity, when I was unpacking those images (the android and
> ubuntu images from the firefly website) with the various tools, I did
> find a RKLoader.bin (which, I believe implements the loader code you
> described the other day on IRC) but the unpacking never produced a "DRAM
> init" chunk. Any idea why there doesn't appear to be a "DRAM init" code
> section in those images?

https://github.com/apxii/rkboottools

Regards,
Reply all
Reply to author
Forward
0 new messages