summaryrefslogtreecommitdiffstats
path: root/examples/device-integration/README
blob: cc91335845d7b6e72939f0dd743d8c51b2ebfa18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
SUMMARY

    This directory contains OTA device integration examples.

    The source code has been fetched from each board's corresponding yocto meta
    layers.

EXAMPLE 1 - nitrogen6x/ (Boundary Devices i.MX6)

    On Boundary Devices boards default 'bootcmd' contains:

    bootcmd =
      for dtype in ${bootdevs}; do
         if itest.s "xusb" == "x${dtype}" ; then
            usb start ;
         fi;
         for disk in 0 1 ; do
            ${dtype} dev ${disk} ;
            for fs in fat ext2 ; do
               ${fs}load ${dtype} ${disk}:1 10008000 /6x_bootscript&& source 10008000 ;
            done ;
         done ;
      done;
      setenv stdout serial,vga ; echo ;
      echo 6x_bootscript not found ; echo ;
      echo serial console at 115200, 8N1 ; echo ;
      echo details at http://boundarydevices.com/6q_bootscript ;
      setenv stdin serial,usbkbd

    From 'bootcmd' command we see that an additional boot script is imported -
    6x_bootscript. By examining the 6x_bootscript we see that a board by default
    imports uEnv.txt file, if it exists. Therefore, to enable OSTree on the board
    we can modify default boot script in the following way:

    Note: To work with the 6x_bootscript you can simply make a copy of it, open
    the copy with 'vim' editor and manually remove the u-boot header.

    Replace:
        if ${fs}load ${dtype} ${disk}:1 12000000 ${bootdir}$dtbname ; then
    With:
        if ${fs}load ${dtype} ${disk}:1 12000000 ${bootdir}/$dtbname ; then

    Replace:
        if ${fs}load ${dtype} ${disk}:1 10800000 ${bootdir}uImage ; then
            if itest.s x$havedtb == x ; then
                bootm 10800000 ;
            else
                bootm 10800000 - 12000000
            fi
        fi
    With:
        # Use kernel_image and ramdisk_image values that were imported from the
        # uEnv.txt, generated by OSTree.
        ${fs}load ${dtype} ${disk}:1 10800000 ${kernel_image}
        setenv ramdisk_addr 0x40000000
        ${fs}load ${dtype} ${disk}:1 ${ramdisk_addr} ${ramdisk_image}

        bootm 10800000 ${ramdisk_addr} 12000000

EXAMPLE 2 - beaglebone/ (BeagleBone Black)

    Tested on a device with u-boot version U-Boot 2013.04-dirty (Jun 19 2013 - 09:57:14).

    On beaglebone default 'bootcmd' contains:

    bootcmd=
        gpio set 53;
        i2c mw 0x24 1 0x3e;
        run findfdt;
        mmc dev 0;

        if mmc rescan ; then
            echo micro SD card found;
            setenv mmcdev 0;
        else
            echo No micro SD card found, setting mmcdev to 1;
            setenv mmcdev 1;
        fi;

            setenv bootpart ${mmcdev}:2;
            mmc dev ${mmcdev};

        if mmc rescan; then
            gpio set 54;
            echo SD/MMC found on device ${mmcdev};
            if run loadbootenv; then
                echo Loaded environment from ${bootenv};
                run importbootenv;
            fi;

            if test -n $uenvcmd; then
                echo Running uenvcmd ...;
                run uenvcmd;
            fi;

            gpio set 55;

            if run loaduimage; then
                gpio set 56;
                run loadfdt;
                run mmcboot;
            fi;
        fi;

    From 'bootcmd' command we see that beaglebone uses 'loadbootenv' to import
    an additional environment. To see what 'loadbootenv' command contains, execute
    the following from u-boot console:

    printenv loadbootenv
    loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}

    printenv bootenv
    bootenv=uEnv.txt

    Now we know that it sources uEnv.txt. To enable OSTree on this board we will
    add our custom commands in the uEnv.txt file.

    Default uEnv.txt contains:

    optargs=consoleblank=0 vt.global_cursor_default=0 quiet
    # extra options to support older u-boot (2013)
    bootfile=zImage
    loadaddr=0x80200000
    loaduimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
    mmcboot=echo Booting from mmc ...; run mmcargs; bootz ${loadaddr} - ${fdtaddr}

    After our changes it contains:

    # OSTree will insert its environment on top of uEnv.txt file.
    bootpart=0:1
    optargs=consoleblank=0 vt.global_cursor_default=0 quiet
    mmcroot=/dev/mmcblk0p2
    loaduimage=load mmc ${bootpart} ${loadaddr} ${kernel_image}
    loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
    loadramdisk=load mmc ${bootpart} ${rdaddr} ${ramdisk_image}
    mmcargs=setenv bootargs $bootargs console=${console} ${optargs} root=${mmcroot} rootfstype=${mmcrootfstype}
    mmcboot=run loadramdisk; echo Booting from mmc ....; run mmcargs; bootz ${loadaddr} ${rdaddr} ${fdtaddr}

    When writing custom uEnv.txt, we can assume that OSTree's environment
    (kernel_image and etc) is already defined. OSTree merges its environment
    variables at the top of uEnv.txt file. You can see an example of this when running
    'qt-ostree' with the following arguments:

    ./qt-ostree --create-ota-sysroot \
                --uboot-env-file uEnv.txt \ (your custom uEnv.txt)
                --sysroot-image-path $SYSROOT_IMAGE_PATH \
                --initramfs $INITRAMFS

    Examine the generated $WORKDIR/sysroot/boot/uEnv.txt file.

EXAMPLE 3 - colibri-vf/ (Toradex Colibri VF)

    On this board default 'bootcmd' does not source any external environment.
    There are several options what we can do:

    1) Update environment directly on the board.

       setenv loadbootenv 'load mmc 0 ${loadaddr} uEnv.txt'
       setenv importbootenv 'echo Importing environment from mmc ...; env import -t $loadaddr $filesize'
       setenv bootcmd 'if run loadbootenv; then echo Loaded environment from uEnv.txt; run importbootenv; fi; run sdboot; run ubiboot; run nfsboot'
       saveenv

       Where our uEnv.txt contains:

       # OSTree will insert its environment on top of uEnv.txt file.
       bootpart=0:1
       ramdisk_addr_r=0x86000000
       loaduimage=load mmc ${bootpart} ${kernel_addr_r} ${kernel_image}
       loadfdt=load mmc ${bootpart} ${fdt_addr_r} ${bootdir}/${soc}-colibri-${fdt_board}.dtb
       loadramdisk=load mmc ${bootpart} ${ramdisk_addr_r} ${ramdisk_image}
       sdboot=run setup; setenv bootargs ${bootargs} ${defargs} ${sdargs} ${mtdparts} ${setupargs} ${vidargs}; echo Booting from MMC/SD card...; run loaduimage && run loadfdt && run loadramdisk && bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}

    2) Update u-boot configuration for the board.

       This can be done by editing include/configs/colibri_vf.h in the u-boot
       repository.

        #define CONFIG_BOOTCOMMAND
        #define CONFIG_EXTRA_ENV_SETTINGS

EXAMPLE 4 - imx6qsabresd/ (Freescale SABRE SD i.MX6)

    On this board default 'bootcmd' runs 'loadbootscript' to load an additional
    environment.

    loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};

    We see that assumption is that boot files are on FAT partition (fatload). This
    won't work because we require a file system with symbolic link support. By
    default we format boot partition as ext2, so we need to change the boot script
    accordingly:

    setenv loadbootscript 'ext2load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script}'
    saveenv

    Find the name of the boot script:

    printenv script
    script=boot.scr

    Add OSTree support by creating boot.scr file with the following contents:

    ext2load mmc ${mmcdev}:${mmcpart} ${loadaddr} uEnv.txt
    echo Importing environment from mmc ...
    env import -t $loadaddr $filesize
    setenv ramdisk_addr 0x24000000
    ext2load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${kernel_image}
    ext2load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${bootdir}/${fdt_file}
    ext2load mmc ${mmcdev}:${mmcpart} ${ramdisk_addr} ${ramdisk_image}
    echo Booting from mmc ...
    run videoargs
    setenv bootargs ${bootargs} console=${console},${baudrate} video=${video} consoleblank=0 vt.global_cursor_default=0 root=${mmcroot}
    bootz ${loadaddr} ${ramdisk_addr} ${fdt_addr}