imx8m: config: convert to bootm_size
[platform/kernel/u-boot.git] / include / configs / siemens-env-common.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2
3 /* Common env settings */
4
5 /** set_bootargs()
6  * input:
7  *      console:        string, tty, etc.
8  *      baudrate:       string, tty baudrate
9  *      testargs:       string
10  *      optargs:        string
11  * output:
12  *      bootargs:       string, default boot string
13  */
14 #define ENV_BOOTARGS_DEFAULT "set_bootargs=" \
15         "setenv bootargs " \
16                 "console=${console} " \
17                 "${testargs} " \
18                 "${optargs}\0"
19
20 /** set_bootargs_net()
21  * input:
22  *      kernel_name:
23  *      dtb_name:
24  *      project_dir:
25  * output:
26  */
27 #define ENV_NET_FCT_NETARGS "set_bootargs_net=" \
28         "run set_bootargs;" \
29         "setenv bootfile ${project_dir}/boot/${kernel_name};" \
30         "setenv bootdtb ${project_dir}/boot/${dtb_name_nfs}.dtb;" \
31         "setenv rootpath /home/projects/${project_dir}/;" \
32         "setenv bootargs ${bootargs} " \
33                 "root=/dev/nfs " \
34                 "nfsroot=${serverip}:${rootpath},${nfsopts} " \
35                 "ip=${ipaddr}:${serverip}:" \
36                         "${gatewayip}:${netmask}:${hostname}:eth0:off\0"
37
38 /** net_nfs()
39  * input:
40  * output:
41  */
42 #define ENV_NET_FCT_BOOT "net_nfs=" \
43         "echo Booting from network ...; " \
44         "run set_bootargs_net; " \
45         "tftpboot ${dtb_loadaddr} ${serverip}:${bootdtb};" \
46         "if test $? -eq 1;" \
47         "then " \
48                 "echo Loading default.dtb!;" \
49                 "tftpboot ${dtb_loadaddr} ${serverip}:${project_dir}/boot/${dtb_name_default}.dtb;" \
50         "fi;" \
51         "tftpboot ${kernel_loadaddr} ${serverip}:${bootfile};" \
52         "printenv bootargs;" \
53         "booti ${kernel_loadaddr} - ${dtb_loadaddr}\0"
54
55 /** check_update()
56  * input:
57  *      upgrade_available:      [0|1],  if set to 1 check bootcount variables
58  *      bootcount:              int,    bootcount
59  *      bootlimit:              int,    limit cootcount
60  *      toggle_partition():     -       toggles active partition set
61  * output:
62  *      upgrade_available:      [0|1],  set to 0 if bootcount > bootlimit
63  */
64 #define ENV_FCT_CHECK_UPGRADE "check_upgrade="\
65         "if test ${upgrade_available} -eq 1; " \
66         "then " \
67                 "echo  upgrade_available is set; " \
68                 "if test ${bootcount} -gt ${bootlimit}; " \
69                 "then " \
70                         "setenv upgrade_available 0;" \
71                         "echo toggle partition;" \
72                         "run toggle_partition;" \
73                 "fi;" \
74         "fi;\0"
75
76 /** toggle_partition()
77  * input:
78  *      partitionset_active:    [A|B],  selected partition set
79  * output:
80  *      partitionset_active:    [A|B],  toggle
81  */
82 #define ENV_FCT_TOGGLE_PARTITION "toggle_partition="\
83         "setenv ${partitionset_active} true;" \
84         "if test -n ${A}; " \
85         "then " \
86                 "setenv partitionset_active B; " \
87                 "env delete A; " \
88         "fi;" \
89         "if test -n ${B}; "\
90         "then " \
91                 "setenv partitionset_active A; " \
92                 "env delete B; " \
93         "fi;" \
94         "saveenv\0"
95
96 /** set_partition()
97  * input:
98  *      partitionset_active:    [A|B],  selected partition set
99  *      rootfs_name:            string, mmc device file in kernel, e.g. /dev/mmcblk0
100  * output:
101  *      mmc_active_vol: string, mmc partition device file in kernel, e.g. /dev/mmcblk0p2
102  *      mmc_part_nr:            int,    partition number of mmc, e.g. /dev/mmcblk0p2 --> 2
103  */
104 #define ENV_EMMC_FCT_SET_ACTIVE_PARTITION "set_partition=" \
105         "setenv ${partitionset_active} true;" \
106         "if test -n ${A}; " \
107         "then " \
108                 "setenv mmc_part_nr 1;" \
109         "fi;" \
110         "if test -n ${B}; " \
111         "then " \
112                 "setenv mmc_part_nr 2;" \
113         "fi;" \
114         "setenv mmc_active_vol ${rootfs_name}p${mmc_part_nr} \0"
115
116 /** set_bootargs_mmc()
117  * input:
118  *      bootargs:               string, default bootargs
119  *      mmc_active_vol          string, mmc partition device file in kernel, e.g. /dev/mmcblk0p2
120  *      ip_method:              string, [none|?]
121  * output:
122  *      bootargs:               string
123  */
124 #define ENV_EMMC_FCT_SET_EMMC_BOOTARGS "set_bootargs_mmc=" \
125         "setenv bootargs ${bootargs} " \
126                 "root=${mmc_active_vol} rw " \
127                 "rootdelay=1 rootwait " \
128                 "rootfstype=ext4 " \
129                 "ip=${ip_method} \0"
130
131 /** mmc_load_bootfiles()
132  * input:
133  *      mmc_part_nr:
134  *      dtb_loadaddr:
135  *      dtb_name:
136  *      kernel_loadaddr:
137  *      kernel_name:
138  */
139 #define ENV_EMMC_FCT_LOADFROM_EMMC "mmc_load_bootfiles=" \
140         "echo Loading from eMMC ...;" \
141         "ext4load mmc 0:${mmc_part_nr} ${dtb_loadaddr} boot/${dtb_name}.dtb;" \
142         "if test $? -eq 1;" \
143         "then " \
144                 "echo Loading default.dtb!;" \
145                 "ext4load mmc 0:${mmc_part_nr} ${dtb_loadaddr} boot/${dtb_name_default}.dtb;" \
146         "fi;" \
147         "ext4load mmc 0:${mmc_part_nr} ${kernel_loadaddr} boot/${kernel_name};" \
148         "printenv bootargs;\0"
149
150 /** mmc_boot()
151  * input:
152  *      mmc_part_nr:
153  *      dtb_loadaddr:
154  *      dtb_name:
155  *      kernel_loadaddr:
156  *      kernel_name:
157  */
158 #define ENV_EMMC_FCT_EMMC_BOOT "mmc_boot=" \
159         "run set_bootargs;" \
160         "run check_upgrade; " \
161         "run set_partition;" \
162         "run set_bootargs_mmc;" \
163         "run mmc_load_bootfiles;" \
164         "echo Booting from eMMC ...; " \
165         "booti ${kernel_loadaddr} - ${dtb_loadaddr} \0"
166
167 #define ENV_EMMC_ALIASES "" \
168         "flash_self=run mmc_boot\0" \
169         "flash_self_test=setenv testargs test; " \
170                 "run mmc_boot\0"
171
172 #define ENV_COMMON "" \
173         "project_dir=targetdir/rootfs\0" \
174         "serverip=192.168.251.2\0" \
175         "ipaddr=192.168.251.1\0" \
176         "dtb_name_nfs=default\0" \
177         "dtb_name_default=default\0" \
178         "kernel_name=Image\0" \
179         "partitionset_active=A\0" \
180         "dtb_loadaddr=0x83000000\0" \
181         "kernel_loadaddr=0x80280000\0" \
182         "ip_method=none\0" \
183         "rootfs_name=/dev/mmcblk0\0" \
184         "upgrade_available=0\0" \
185         "bootlimit=3\0" \
186         "altbootcmd=run bootcmd\0" \
187         "optargs=\0" \
188
189 /**********************************************************************/
190
191 #define ENV_EMMC        ENV_EMMC_FCT_EMMC_BOOT \
192                         ENV_EMMC_FCT_LOADFROM_EMMC \
193                         ENV_EMMC_FCT_SET_EMMC_BOOTARGS \
194                         ENV_EMMC_FCT_SET_ACTIVE_PARTITION \
195                         ENV_FCT_CHECK_UPGRADE \
196                         ENV_EMMC_ALIASES \
197                         ENV_FCT_TOGGLE_PARTITION
198
199 #define ENV_NET         ENV_NET_FCT_BOOT \
200                         ENV_NET_FCT_NETARGS \
201                         ENV_BOOTARGS_DEFAULT