mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: B Gol <behnam_golds@yahoo.com>
To: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: How to use eMMC/SD DOS partitions as backend for the state framework?
Date: Tue, 13 Jun 2017 14:49:36 +0000 (UTC)	[thread overview]
Message-ID: <1982917789.2703351.1497365376201@mail.yahoo.com> (raw)
In-Reply-To: <1982917789.2703351.1497365376201.ref@mail.yahoo.com>

Hi,

Thanks for the quick answer and putting me into the right

direction.

All I was trying to do was getting the Rauc update system

work with barebox state framework , and it took almost two

weeks of my life to get it done. Now that it is working as

expected, it is time to give back to the community, or in

other words "state framework for dummies" .


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


First of all this is what I have added or modified in my


dts file (I have a beaglebone black so that would be

the am335x-boneblack.dts file in the barebox source path) :


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


*** I modified this part :



&mmc1 {

vmmc-supply = <&vmmcsd_fixed>;


mmc1_state: state@0x96ad000 {

reg = <0x96ad000 0x4fffff>;

label = "state-sd";

};

};


*** and added this part to the end of the dts file:



/ {

state:  state {

magic = <0x27031977>;

compatible = "barebox,state";

backend-type = "raw";

backend-storage-type = "circular";

backend-stridesize = <0x500>;

backend = <&mmc1_state>;

bootstate {

last_chosen {

reg = <0x5 0x4>;

type = "uint32";

default = <0x1>;

};

system0.boot {

reg = <0x20 0xa>;

type = "string";

default = "system0";

};

system0.remaining_attempts {

reg = <0x2b 0x4>;

type = "uint32";

default = <0x3>;

};

system0.priority {

reg = <0x31 0x4>;

type = "uint32";

default = <0x15>;

};


system1.boot {

reg = <0x60 0xa>;

type = "string";

default = "system1";

};

system1.remaining_attempts {

reg = <0x6b 0x4>;

type = "uint32";

default = <0x3>;

};

system1.priority {

reg = <0x76 0x4>;

type = "uint32";

default = <0x14>;

};

};

};


aliases {

state = &state;

};


};

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


1) The &mmc1 was already in the dts file , I just added

the mmc1_state: ... {...} part to it.


2) The reg = <0x96ad000 0x4fffff> part was also a


challenge for me to figure out. Turned out those

numbers are there to specify the boundaries of the

state partition. You can either find it with fdisk -l -u

in your linux shell or with the devinfo command in the barebox

shell (second approach is recommended since it is already in Hex

and bytes compared to Dec and sectors with fdisk )



this is part of the output I got from devinfo:


`-- 0x096ad000-0x09bacfff ( 5 MiB): /dev/mmc0.6


(do not confuse mmc0 in the output with mmc1 in

your dts file, mmc0 is just an alias to mmc1.

so if you want to specify mmc1 you have to write


mmc2 in the dts file)

the first number would be the start address , and

last_address minus first_address would result in


size of your intended partition


0x09bacff - 0x096ad000 = 0x4fffff


hence 

reg = <0x96ad000 0x4fffff>;


3) For the *types I first started with "dtb" and "direct",

but got very weird responses (some gibberish on the console after

every reboot and some weird characters in my state variables) so I

changed them to "raw" and "circular" and I haven't seen any of


the weirdness since.




4) You also have to create some nv variables to get it to work:

from the barebox shell :


nv bootchooser.state_prefix="state.bootstate"

nv boot.default="bootchooser net"


or you could do it before compiling the barebox:


make a file named "bootchooser.state_prefix" containing


"state.bootstate" string.

make a file named "boot.default" containing "bootchooser net"

string.(you can change net with recovery or anything you have in mind,

barebox will try to boot net if the bootchooser fails, or you could remove

it from the string altogether).


And put both of them in the following path of the barebox


source code:



/source-path/barebox-yyyy.mm.d/defaultenv/defaultenv-2-base/nv/



5) You also need to make system0 and system1 (based on your naming scheme


in the dts file) scripts in the following directory:


in the barebox environment:

/env/boot/


or in the source code path before compiling:


/source-path/barebox-yyyy.mm.d/defaultenv/boot/



I just put my boot scripts here for example:


system0 boot script:

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


#!/bin/sh


mount /dev/mmc0.1

global.bootm.image=/mnt/mmc0.1/boot/zImage-4.8.12

global.bootm.oftree=/mnt/mmc0.1/boot/devicetree-zImage-am335x-boneblack.dtb

global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootfstype=ext4"

global linux.bootargs.base="console=ttyO0,115200"

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


system1 boot script:


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


#!/bin/sh


mount /dev/mmc0.2

global.bootm.image=/mnt/mmc0.2/boot/zImage-4.8.12

global.bootm.oftree=/mnt/mmc0.2/boot/devicetree-zImage-am335x-boneblack.dtb

global.linux.bootargs.dyn.root="root=/dev/mmcblk0p3 rootfstype=ext4"

global linux.bootargs.base="console=ttyO0,115200"


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



I hope this helps some barebox noobies like me in the future.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

       reply	other threads:[~2017-06-13 14:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1982917789.2703351.1497365376201.ref@mail.yahoo.com>
2017-06-13 14:49 ` B Gol [this message]
     [not found] <1270235505.6719556.1497082449606.ref@mail.yahoo.com>
2017-06-10  8:14 ` B Gol
2017-06-13  7:34   ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1982917789.2703351.1497365376201@mail.yahoo.com \
    --to=behnam_golds@yahoo.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox