Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
u-boot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
certo
u-boot
Commits
00a50c25
Commit
00a50c25
authored
Mar 23, 2019
by
Vladimir Bashkirtsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added mender support to u-boot
parent
b0689d5e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
798 additions
and
0 deletions
+798
-0
Makefile
Makefile
+141
-0
u-boot-2018.05-mender.patch
u-boot-2018.05-mender.patch
+302
-0
u-boot-2018.05-sunxi_wdt.patch
u-boot-2018.05-sunxi_wdt.patch
+355
-0
No files found.
Makefile
View file @
00a50c25
...
...
@@ -35,6 +35,49 @@ define FW_ENV_OPIPLUS2E
endef
export
FW_ENV_OPIPLUS2E
opiplus2e-mender
:
opiplus2e-boot-cmd-mender opiplus2e-fw_env.config-mender
tar
xf u-boot-2018.05.tar.gz
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-serial-number-fix.patch
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-sunxi-h3-Fix-PLL1-setup-to-never-use-dividers.patch
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-mender.patch
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-sunxi_wdt.patch
$(MAKE)
-C
u-boot-2018.05 orangepi_plus2e_defconfig
@
echo
"CONFIG_ENV_IS_IN_MMC=y"
>>
u-boot-2018.05/.config
@
echo
"CONFIG_WDT=y"
>>
u-boot-2018.05/.config
@
echo
"CONFIG_WDT_SUNXI=y"
>>
u-boot-2018.05/.config
$(MAKE)
-C
u-boot-2018.05 oldconfig
$(MAKE)
-C
u-boot-2018.05
mount /dev/
$(DISK)
1 /uboot
dd
if
=
/dev/zero
of
=
/dev/
$(ROOT_DEVICE)
bs
=
512
seek
=
1
count
=
49151
dd
if
=
u-boot-2018.05/u-boot-sunxi-with-spl.bin
of
=
/dev/
$(ROOT_DEVICE)
bs
=
1024
seek
=
8
@
echo
"
$$
BOOTCMD_OPIPLUS2E_MENDER"
>
u-boot-2018.05/boot.cmd
u-boot-2018.05/tools/mkimage
-C
none
-A
arm
-T
script
-d
u-boot-2018.05/boot.cmd /uboot/boot.scr
$(MAKE)
-C
u-boot-2018.05 envtools
cp
u-boot-2018.05/tools/env/fw_printenv /sbin/fw_printenv
ln
-sf
/sbin/fw_printenv /sbin/fw_setenv
@
echo
"
$$
FW_ENV_OPIPLUS2E_MENDER"
>
/etc/fw_env.config
/sbin/fw_setenv reset
umount /dev/
$(DISK)
1
rm
-rf
u-boot-2018.05
opiplus2e-boot-cmd-mender
:
define
BOOTCMD_OPIPLUS2E_MENDER
run
mender_setup
load
$${mender_uboot_root}
$${kernel_addr_r}
boot/zImage
load
$${mender_uboot_root}
$${fdt_addr_r}
boot/machine.dtb
setenv
bootargs
console
=
tty1
panic
=
10
panic_on_oops
=
1
root
=
$
${mender_kernel_root}
rootfstype
=
ext4 ro rootwait
elevator
=
noop sunxi-wdt.nowayout
=
1 quiet
loglevel
=
3 systemd.show_status
=
1
bootz
$${kernel_addr_r}
-
$${fdt_addr_r}
run
mender_try_to_recover
endef
export
BOOTCMD_OPIPLUS2E_MENDER
opiplus2e-fw_env.config-mender
:
define
FW_ENV_OPIPLUS2E_MENDER
/dev/$(ROOT_DEVICE)
0x400000
0x20000
/dev/$(ROOT_DEVICE)
0x800000
0x20000
endef
export
FW_ENV_OPIPLUS2E_MENDER
opipcplus
:
opipcplus-boot-cmd opipcplus-fw_env.config
tar
xf u-boot-2018.05.tar.gz
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-serial-number-fix.patch
...
...
@@ -72,6 +115,49 @@ define FW_ENV_OPIPCPLUS
endef
export
FW_ENV_OPIPCPLUS
opipcplus-mender
:
opipcplus-boot-cmd-mender opipcplus-fw_env.config-mender
tar
xf u-boot-2018.05.tar.gz
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-serial-number-fix.patch
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-sunxi-h3-Fix-PLL1-setup-to-never-use-dividers.patch
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-mender.patch
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-sunxi_wdt.patch
$(MAKE)
-C
u-boot-2018.05 orangepi_pc_plus_defconfig
@
echo
"CONFIG_ENV_IS_IN_MMC=y"
>>
u-boot-2018.05/.config
@
echo
"CONFIG_WDT=y"
>>
u-boot-2018.05/.config
@
echo
"CONFIG_WDT_SUNXI=y"
>>
u-boot-2018.05/.config
$(MAKE)
-C
u-boot-2018.05 oldconfig
$(MAKE)
-C
u-boot-2018.05
mount /dev/
$(DISK)
1 /uboot
dd
if
=
/dev/zero
of
=
/dev/
$(ROOT_DEVICE)
bs
=
512
seek
=
1
count
=
49151
dd
if
=
u-boot-2018.05/u-boot-sunxi-with-spl.bin
of
=
/dev/
$(ROOT_DEVICE)
bs
=
1024
seek
=
8
@
echo
"
$$
BOOTCMD_OPIPCPLUS_MENDER"
>
u-boot-2018.05/boot.cmd
u-boot-2018.05/tools/mkimage
-C
none
-A
arm
-T
script
-d
u-boot-2018.05/boot.cmd /uboot/boot.scr
$(MAKE)
-C
u-boot-2018.05 envtools
cp
u-boot-2018.05/tools/env/fw_printenv /sbin/fw_printenv
ln
-sf
/sbin/fw_printenv /sbin/fw_setenv
@
echo
"
$$
FW_ENV_OPIPCPLUS_MENDER"
>
/etc/fw_env.config
/sbin/fw_setenv reset
umount /dev/
$(DISK)
1
rm
-rf
u-boot-2018.05
opipcplus-boot-cmd-mender
:
define
BOOTCMD_OPIPCPLUS_MENDER
run
mender_setup
load
$${mender_uboot_root}
$${kernel_addr_r}
boot/zImage
load
$${mender_uboot_root}
$${fdt_addr_r}
boot/machine.dtb
setenv
bootargs
console
=
tty1
panic
=
10
panic_on_oops
=
1
root
=
$
${mender_kernel_root}
rootfstype
=
ext4 ro rootwait
elevator
=
noop sunxi-wdt.nowayout
=
1 quiet
loglevel
=
3 systemd.show_status
=
1
bootz
$${kernel_addr_r}
-
$${fdt_addr_r}
run
mender_try_to_recover
endef
export
BOOTCMD_OPIPCPLUS_MENDER
opipcplus-fw_env.config-mender
:
define
FW_ENV_OPIPCPLUS_MENDER
/dev/$(ROOT_DEVICE)
0x400000
0x20000
/dev/$(ROOT_DEVICE)
0x800000
0x20000
endef
export
FW_ENV_OPIPCPLUS_MENDER
rpi3b
:
rpi3b-boot-cmd rpi3b-fw_env.config rpi3b-config
tar
xf u-boot-2018.05.tar.gz
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-serial-number-fix.patch
...
...
@@ -122,3 +208,58 @@ dtparam=spi=on
avoid_warnings
=
2
endef
export
RPI3CONFIG
rpi3b-mender
:
rpi3b-boot-cmd-mender rpi3b-fw_env.config-mender rpi3b-config-mender
tar
xf u-boot-2018.05.tar.gz
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-serial-number-fix.patch
patch
-Np1
-d
u-boot-2018.05 < u-boot-2018.05-mender.patch
$(MAKE)
-C
u-boot-2018.05 rpi_3_defconfig
@
echo
"CONFIG_ENV_IS_IN_MMC=y"
>>
u-boot-2018.05/.config
@
echo
"CONFIG_BCM2835_WDT=y"
>>
u-boot-2018.05/.config
$(MAKE)
-C
u-boot-2018.05 oldconfig
$(MAKE)
-C
u-boot-2018.05
mount /dev/
$(DISK)
1 /uboot
dd
if
=
/dev/zero
of
=
/dev/
$(ROOT_DEVICE)
bs
=
512
seek
=
1
count
=
49151
cp
u-boot-2018.05/u-boot.bin /uboot/u-boot.bin
@
echo
"
$$
BOOTCMD_RPI3_MENDER"
>
u-boot-2018.05/boot.cmd
u-boot-2018.05/tools/mkimage
-C
none
-A
arm
-T
script
-d
u-boot-2018.05/boot.cmd /uboot/boot.scr
@
echo
"
$$
RPI3CONFIG_MENDER"
>
/uboot/config.txt
tar
xf rpi3-firmware.tar.xz
--no-same-owner
-C
/uboot
$(MAKE)
-C
u-boot-2018.05 envtools
cp
u-boot-2018.05/tools/env/fw_printenv /sbin/fw_printenv
ln
-svf
/sbin/fw_printenv /sbin/fw_setenv
@
echo
"
$$
FW_ENV_RPI3_MENDER"
>
/etc/fw_env.config
/sbin/fw_setenv reset
umount /dev/
$(DISK)
1
rm
-rf
u-boot-2018.05
rpi3b-boot-cmd-mender
:
define
BOOTCMD_RPI3_MENDER
run
mender_setup
load
$${mender_uboot_root}
$${kernel_addr_r}
boot/Image
load
$${mender_uboot_root}
$${fdt_addr_r}
boot/machine.dtb
setenv
bootargs
console
=
tty1
panic
=
10
panic_on_oops
=
1
root
=
$
${mender_kernel_root}
rootfstype
=
ext4 ro rootwait
elevator
=
noop bcm2835-wdt.nowayout
=
1 quiet
loglevel
=
3 systemd.show_status
=
1
booti
$${kernel_addr_r}
-
$${fdt_addr_r}
run
mender_try_to_recover
endef
export
BOOTCMD_RPI3_MENDER
rpi3b-fw_env.config-mender
:
define
FW_ENV_RPI3
/dev/$(ROOT_DEVICE)
0x400000
0x20000
/dev/$(ROOT_DEVICE)
0x800000
0x20000
endef
export
FW_ENV_RPI3_MENDER
rpi3b-config-mender
:
define
RPI3CONFIG_MENDER
enable_uart
=
1
arm_control
=
0x200
device_tree_address
=
0x100
device_tree_end
=
0x8000
kernel
=
u-boot.bin
dtparam
=
i2c_arm
=
on
dtparam
=
spi
=
on
avoid_warnings
=
1
endef
export
RPI3CONFIG_MENDER
u-boot-2018.05-mender.patch
0 → 100644
View file @
00a50c25
diff -uNr u-boot-2018.05/env/Kconfig u-boot-2018.05-mender/env/Kconfig
--- u-boot-2018.05/env/Kconfig 2018-05-08 01:02:36.000000000 +0930
+++ u-boot-2018.05-mender/env/Kconfig 2018-10-14 17:47:13.739770707 +1030
@@ -433,10 +433,8 @@
if ARCH_SUNXI
config ENV_OFFSET
- hex "Environment Offset"
- depends on !ENV_IS_IN_UBI
- depends on !ENV_IS_NOWHERE
- default 0x88000 if ARCH_SUNXI
+ hex "Environment Offset will be set by mender patch"
+ depends on !ARCH_SUNXI
help
Offset from the start of the device (or partition)
diff -uNr u-boot-2018.05/include/config_mender_defines.h u-boot-2018.05-mender/include/config_mender_defines.h
--- u-boot-2018.05/include/config_mender_defines.h 1970-01-01 09:30:00.000000000 +0930
+++ u-boot-2018.05-mender/include/config_mender_defines.h 2018-10-14 17:46:35.818652610 +1030
@@ -0,0 +1,17 @@
+/* Shell variables */
+#define MENDER_BOOT_PART_NUMBER 1
+#define MENDER_ROOTFS_PART_A_NUMBER 2
+#define MENDER_ROOTFS_PART_B_NUMBER 3
+#define MENDER_UBOOT_STORAGE_INTERFACE "mmc"
+#define MENDER_UBOOT_STORAGE_DEVICE 0
+
+/* BB variables. */
+#define MENDER_STORAGE_DEVICE_BASE "/dev/mmcblk0p"
+#define MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_1 0x400000
+#define MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_2 0x800000
+#define MENDER_ROOTFS_PART_A_NAME "ubi0:rootfsa"
+#define MENDER_ROOTFS_PART_B_NAME "ubi0:rootfsb"
+#define MENDER_MTD_UBI_DEVICE_NAME "ubi"
+
+/* For sanity checks. */
+#define MENDER_BOOTENV_SIZE 0x20000
diff -uNr u-boot-2018.05/include/config_mender.h u-boot-2018.05-mender/include/config_mender.h
--- u-boot-2018.05/include/config_mender.h 1970-01-01 09:30:00.000000000 +0930
+++ u-boot-2018.05-mender/include/config_mender.h 2018-10-14 17:46:35.818652610 +1030
@@ -0,0 +1,83 @@
+/*
+ Copyright 2017 Northern.tech AS
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifndef HEADER_CONFIG_MENDER_H
+#define HEADER_CONFIG_MENDER_H
+
+/* Avoid Mender specific code if we are just probing for configuration. */
+#ifndef MENDER_AUTO_PROBING
+
+#include <config_mender_defines.h>
+
+#if !defined(CONFIG_ENV_IS_IN_MMC) && !defined(CONFIG_ENV_IS_IN_NAND) && !defined(CONFIG_ENV_IS_IN_FLASH)
+# error CONFIG_ENV_IS_IN_MMC, CONFIG_ENV_IS_IN_NAND or CONFIG_ENV_IS_IN_FLASH is required for Mender to work
+#endif
+
+#ifndef CONFIG_BOOTCOUNT_LIMIT
+# error CONFIG_BOOTCOUNT_LIMIT is required for Mender to work
+#endif
+
+/* Currently Mender needs bootcount to reside in environment. */
+#ifndef CONFIG_BOOTCOUNT_ENV
+# error CONFIG_BOOTCOUNT_ENV is required for Mender to work
+#endif
+
+#ifdef CONFIG_SYS_MMC_ENV_DEV
+# error CONFIG_SYS_MMC_ENV_DEV should not be defined explicitly (will be auto-configured).
+#endif
+#ifdef CONFIG_SYS_MMC_ENV_PART
+# error CONFIG_SYS_MMC_ENV_PART should not be defined explicitly (will be auto-configured).
+#endif
+#ifdef CONFIG_ENV_OFFSET
+# error CONFIG_ENV_OFFSET should not be defined explicitly (will be auto-configured).
+#endif
+#ifdef CONFIG_ENV_OFFSET_REDUND
+# error CONFIG_ENV_OFFSET_REDUND should not be defined explicitly (will be auto-configured).
+#endif
+
+#if MENDER_BOOTENV_SIZE != CONFIG_ENV_SIZE
+# error 'CONFIG_ENV_SIZE' define must be equal to bitbake variable 'BOOTENV_SIZE' set in U-Boot build recipe.
+#endif
+
+#ifdef MENDER_BOOTENV_RANGE
+
+#ifndef CONFIG_ENV_RANGE
+#error bitbake variable 'BOOTENV_RANGE' is set U-Boot recipe, but CONFIG_ENV_RANGE is not set in configuration
+#endif /* CONFIG_ENV_RANGE */
+
+#if MENDER_BOOTENV_RANGE != CONFIG_ENV_RANGE
+#error 'CONFIG_ENV_RANGE' define must be equal to bitbake variable 'BOOTENV_RANGE' set in U-Boot build recipe.
+#endif
+
+#else
+
+#ifdef CONFIG_ENV_RANGE
+#error CONFIG_ENV_RANGE is set but BOOTENV_RANGE is not configured in U-Boot build recipe.
+#endif
+
+#endif /* MENDER_BOOTENV_RANGE */
+
+#define CONFIG_SYS_MMC_ENV_DEV MENDER_UBOOT_STORAGE_DEVICE
+/* Use MMC partition zero to select whole user area of memory card. */
+#define CONFIG_SYS_MMC_ENV_PART 0
+#define CONFIG_ENV_OFFSET MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_1
+#define CONFIG_ENV_OFFSET_REDUND MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_2
+
+#endif /* !MENDER_AUTO_PROBING */
+
+#endif /* HEADER_CONFIG_MENDER_H */
diff -uNr u-boot-2018.05/include/configs/rpi.h u-boot-2018.05-mender/include/configs/rpi.h
--- u-boot-2018.05/include/configs/rpi.h 2018-05-08 01:02:36.000000000 +0930
+++ u-boot-2018.05-mender/include/configs/rpi.h 2018-10-14 17:46:35.818652610 +1030
@@ -73,7 +73,9 @@
#define CONFIG_SYS_CBSIZE 1024
/* Environment */
-#define CONFIG_ENV_SIZE SZ_16K
+#define CONFIG_ENV_SIZE SZ_128K
+#define CONFIG_BOOTCOUNT_LIMIT
+#define CONFIG_BOOTCOUNT_ENV
#define CONFIG_SYS_LOAD_ADDR 0x1000000
#define CONFIG_PREBOOT "usb start"
diff -uNr u-boot-2018.05/include/configs/sun8i.h u-boot-2018.05-mender/include/configs/sun8i.h
--- u-boot-2018.05/include/configs/sun8i.h 2018-05-08 01:02:36.000000000 +0930
+++ u-boot-2018.05-mender/include/configs/sun8i.h 2018-10-14 17:46:35.818652610 +1030
@@ -31,4 +31,7 @@
*/
#include <configs/sunxi-common.h>
+#define CONFIG_BOOTCOUNT_LIMIT
+#define CONFIG_BOOTCOUNT_ENV
+
#endif /* __CONFIG_H */
diff -uNr u-boot-2018.05/include/configs/sunxi-common.h u-boot-2018.05-mender/include/configs/sunxi-common.h
--- u-boot-2018.05/include/configs/sunxi-common.h 2018-05-08 01:02:36.000000000 +0930
+++ u-boot-2018.05-mender/include/configs/sunxi-common.h 2018-10-14 17:48:31.665013407 +1030
@@ -150,16 +150,9 @@
#define CONFIG_BOARD_SIZE_LIMIT 0x7e000
#endif
-#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
-/* If we have two devices (most likely eMMC + MMC), favour the eMMC */
-#define CONFIG_SYS_MMC_ENV_DEV 1
-#else
-/* Otherwise, use the only device we have */
-#define CONFIG_SYS_MMC_ENV_DEV 0
-#endif
#define CONFIG_SYS_MMC_MAX_DEVICE 4
#elif defined(CONFIG_ENV_IS_NOWHERE)
-#define CONFIG_ENV_SIZE (128 << 10)
+#define CONFIG_ENV_SIZE SZ_128K
#endif
#ifndef CONFIG_MACH_SUN8I_V3S
diff -uNr u-boot-2018.05/include/env_default.h u-boot-2018.05-mender/include/env_default.h
--- u-boot-2018.05/include/env_default.h 2018-05-08 01:02:36.000000000 +0930
+++ u-boot-2018.05-mender/include/env_default.h 2018-10-14 17:46:35.818652610 +1030
@@ -9,6 +9,8 @@
#include <env_callback.h>
+#include <env_mender.h>
+
#ifdef DEFAULT_ENV_INSTANCE_EMBEDDED
env_t environment __UBOOT_ENV_SECTION__(environment) = {
ENV_CRC, /* CRC Sum */
@@ -21,6 +23,7 @@
#else
const uchar default_environment[] = {
#endif
+ MENDER_ENV_SETTINGS
#ifndef CONFIG_USE_DEFAULT_ENV_FILE
#ifdef CONFIG_ENV_CALLBACK_LIST_DEFAULT
ENV_CALLBACK_VAR "=" CONFIG_ENV_CALLBACK_LIST_DEFAULT "\0"
@@ -32,7 +35,7 @@
"bootargs=" CONFIG_BOOTARGS "\0"
#endif
#ifdef CONFIG_BOOTCOMMAND
- "bootcmd=" CONFIG_BOOTCOMMAND "\0"
+ "bootcmd=" CONFIG_BOOTCOMMAND "\0"
#endif
#ifdef CONFIG_RAMBOOTCOMMAND
"ramboot=" CONFIG_RAMBOOTCOMMAND "\0"
diff -uNr u-boot-2018.05/include/env_mender.h u-boot-2018.05-mender/include/env_mender.h
--- u-boot-2018.05/include/env_mender.h 1970-01-01 09:30:00.000000000 +0930
+++ u-boot-2018.05-mender/include/env_mender.h 2018-10-14 17:46:35.818652610 +1030
@@ -0,0 +1,86 @@
+/*
+ Copyright 2017 Northern.tech AS
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifndef HEADER_ENV_MENDER_H
+#define HEADER_ENV_MENDER_H
+
+/* Avoid Mender specific code if we are just probing for configuration. */
+#ifdef MENDER_AUTO_PROBING
+#define MENDER_ENV_SETTINGS
+#else
+
+#include <config_mender_defines.h>
+
+#ifdef MENDER_NO_DEFAULT_ALTBOOTCMD
+# define MENDER_DEFAULT_ALTBOOTCMD
+#else
+# define MENDER_DEFAULT_ALTBOOTCMD "altbootcmd=run mender_altbootcmd; " \
+ "run bootcmd\0"
+#endif
+
+#define MENDER_ENV_SETTINGS \
+ MENDER_DEFAULT_ALTBOOTCMD \
+ "bootlimit=1\0" \
+ "bootcount=0\0" \
+ \
+ "upgrade_available=0\0" \
+ \
+ "mender_mtd_ubi_dev_name=" MENDER_MTD_UBI_DEVICE_NAME "\0" \
+ \
+ "mender_boot_part=" __stringify(MENDER_ROOTFS_PART_A_NUMBER) "\0" \
+ \
+ "mender_uboot_boot=" MENDER_UBOOT_STORAGE_INTERFACE " " __stringify(MENDER_UBOOT_STORAGE_DEVICE) ":" __stringify(MENDER_BOOT_PART_NUMBER) "\0" \
+ \
+ "mender_uboot_if=" MENDER_UBOOT_STORAGE_INTERFACE "\0" \
+ \
+ "mender_uboot_dev=" __stringify(MENDER_UBOOT_STORAGE_DEVICE) "\0" \
+ \
+ "mender_setup=" \
+ "setenv mender_kernel_root " MENDER_STORAGE_DEVICE_BASE "${mender_boot_part}; " \
+ "if test ${mender_boot_part} = " __stringify(MENDER_ROOTFS_PART_A_NUMBER) "; " \
+ "then " \
+ "setenv mender_boot_part_name " MENDER_ROOTFS_PART_A_NAME "; " \
+ "else " \
+ "setenv mender_boot_part_name " MENDER_ROOTFS_PART_B_NAME "; " \
+ "fi; " \
+ "setenv mender_kernel_root_name ${mender_boot_part_name}; " \
+ "setenv mender_uboot_root " MENDER_UBOOT_STORAGE_INTERFACE " " __stringify(MENDER_UBOOT_STORAGE_DEVICE) ":${mender_boot_part}; " \
+ "setenv mender_uboot_root_name ${mender_boot_part_name}; " \
+ "setenv expand_bootargs \"setenv bootargs \\\\\"${bootargs}\\\\\"\"; " \
+ "run expand_bootargs; " \
+ "setenv expand_bootargs\0" \
+ \
+ "mender_altbootcmd=" \
+ "if test ${mender_boot_part} = " __stringify(MENDER_ROOTFS_PART_A_NUMBER) "; " \
+ "then " \
+ "setenv mender_boot_part " __stringify(MENDER_ROOTFS_PART_B_NUMBER) "; " \
+ "else " \
+ "setenv mender_boot_part " __stringify(MENDER_ROOTFS_PART_A_NUMBER) "; " \
+ "fi; " \
+ "setenv upgrade_available 0; " \
+ "saveenv; " \
+ "run mender_setup\0" \
+ \
+ "mender_try_to_recover=" \
+ "if test ${upgrade_available} = 1; " \
+ "then reset; " \
+ "fi\0"
+
+#endif /* !MENDER_AUTO_PROBING */
+
+#endif /* HEADER_ENV_MENDER_H */
diff -uNr u-boot-2018.05/scripts/Makefile.autoconf u-boot-2018.05-mender/scripts/Makefile.autoconf
--- u-boot-2018.05/scripts/Makefile.autoconf 2018-05-08 01:02:36.000000000 +0930
+++ u-boot-2018.05-mender/scripts/Makefile.autoconf 2018-10-14 17:46:35.818652610 +1030
@@ -109,7 +109,8 @@
echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \
echo \#include \<asm/config.h\>; \
echo \#include \<linux/kconfig.h\>; \
- echo \#include \<config_fallbacks.h\>;)
+ echo \#include \<config_fallbacks.h\>; \
+ echo \#include \<config_mender.h\>;)
endef
include/config.h: scripts/Makefile.autoconf create_symlink FORCE
u-boot-2018.05-sunxi_wdt.patch
0 → 100644
View file @
00a50c25
diff -uNr u-boot-2018.05/board/sunxi/board.c u-boot-2018.05-sunxi_wdt/board/sunxi/board.c
--- u-boot-2018.05/board/sunxi/board.c 2018-05-08 01:02:36.000000000 +0930
+++ u-boot-2018.05-sunxi_wdt/board/sunxi/board.c 2018-09-08 01:58:12.034023066 +0930
@@ -34,6 +34,7 @@
#include <spl.h>
#include <sy8106a.h>
#include <asm/setup.h>
+#include <dm/uclass.h>
#if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD)
/* So that we can use pin names in Kconfig and sunxi_name_to_gpio() */
@@ -253,6 +254,20 @@
return soft_i2c_board_init();
}
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT_SUNXI)
+static struct udevice *watchdog_dev = NULL;
+
+void arch_preboot_os(void)
+{
+ if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
+ puts("Cannot find Sunxi watchdog!\n");
+ } else {
+ wdt_start(watchdog_dev, (u64) 16 * 1000, 0);
+ puts("Watchdog engaged\n");
+ }
+}
+#endif
+
int dram_init(void)
{
gd->ram_size = get_ram_size((long *)PHYS_SDRAM_0, PHYS_SDRAM_0_SIZE);
diff -uNr u-boot-2018.05/drivers/watchdog/Kconfig u-boot-2018.05-sunxi_wdt/drivers/watchdog/Kconfig
--- u-boot-2018.05/drivers/watchdog/Kconfig 2018-05-08 01:02:36.000000000 +0930
+++ u-boot-2018.05-sunxi_wdt/drivers/watchdog/Kconfig 2018-09-08 02:05:10.892277036 +0930
@@ -62,7 +62,7 @@
config WDT_ASPEED
bool "Aspeed ast2400/ast2500 watchdog timer support"
- depends on WDT
+ depends on WDT && ARCH_ASPEED
default y if ARCH_ASPEED
help
Select this to enable watchdog timer for Aspeed ast2500/ast2400 devices.
@@ -81,11 +81,21 @@
config WDT_ORION
bool "Orion watchdog timer support"
- depends on WDT
+ depends on WDT && ARCH_MVEBU
help
Select this to enable Orion watchdog timer, which can be found on some
Marvell Armada chips.
+config WDT_SUNXI
+ bool "Sunxi watchdog timer support"
+ depends on WDT && ARCH_SUNXI
+ default y if ARCH_SUNXI
+ help
+ Select this to enable the Sunxi watchdog
+
+ This provides basic infrastructure to support Sunxi watchdog
+ hardware, with a max timeout of ~16secs.
+
config WDT_CDNS
bool "Cadence watchdog timer support"
depends on WDT
diff -uNr u-boot-2018.05/drivers/watchdog/Makefile u-boot-2018.05-sunxi_wdt/drivers/watchdog/Makefile
--- u-boot-2018.05/drivers/watchdog/Makefile 2018-05-08 01:02:36.000000000 +0930
+++ u-boot-2018.05-sunxi_wdt/drivers/watchdog/Makefile 2018-09-08 02:05:44.645378082 +0930
@@ -20,5 +20,6 @@
obj-$(CONFIG_WDT_BCM6345) += bcm6345_wdt.o
obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o
obj-$(CONFIG_WDT_ORION) += orion_wdt.o
+obj-$(CONFIG_WDT_SUNXI) += sunxi_wdt.o
obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o
obj-$(CONFIG_MPC8xx_WATCHDOG) += mpc8xx_wdt.o
diff -uNr u-boot-2018.05/drivers/watchdog/sunxi_wdt.c u-boot-2018.05-sunxi_wdt/drivers/watchdog/sunxi_wdt.c
--- u-boot-2018.05/drivers/watchdog/sunxi_wdt.c 1970-01-01 09:30:00.000000000 +0930
+++ u-boot-2018.05-sunxi_wdt/drivers/watchdog/sunxi_wdt.c 2018-09-08 01:58:12.035023069 +0930
@@ -0,0 +1,274 @@
+/*
+ * sunxi Watchdog Driver
+ *
+ * Copyright (c) 2018 Vladimir Bashkirtsev
+ * 2013 Carlo Caione
+ * 2012 Henrik Nordstrom
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Based on xen_wdt.c
+ * (c) Copyright 2010 Novell, Inc.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <wdt.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define WDT_MAX_TIMEOUT 16
+#define WDT_MIN_TIMEOUT 1
+#define WDT_TIMEOUT_MASK 0x0F
+
+#define WDT_CTRL_RELOAD ((1 << 0) | (0x0a57 << 1))
+
+#define WDT_MODE_EN (1 << 0)
+
+/*
+ * This structure stores the register offsets for different variants
+ * of Allwinner's watchdog hardware.
+ */
+struct sunxi_wdt_reg {
+ u8 wdt_ctrl;
+ u8 wdt_cfg;
+ u8 wdt_mode;
+ u8 wdt_timeout_shift;
+ u8 wdt_reset_mask;
+ u8 wdt_reset_val;
+};
+
+struct sunxi_wdt_priv {
+ unsigned int timeout;
+ void __iomem *wdt_base;
+ const struct sunxi_wdt_reg *wdt_regs;
+};
+
+/*
+ * wdt_timeout_map maps the watchdog timer interval value in seconds to
+ * the value of the register WDT_MODE at bits .wdt_timeout_shift ~ +3
+ *
+ * [timeout seconds] = register value
+ *
+ */
+
+static const int wdt_timeout_map[] = {
+ [1] = 0x1, /* 1s */
+ [2] = 0x2, /* 2s */
+ [3] = 0x3, /* 3s */
+ [4] = 0x4, /* 4s */
+ [5] = 0x5, /* 5s */
+ [6] = 0x6, /* 6s */
+ [8] = 0x7, /* 8s */
+ [10] = 0x8, /* 10s */
+ [12] = 0x9, /* 12s */
+ [14] = 0xA, /* 14s */
+ [16] = 0xB, /* 16s */
+};
+
+
+static int sunxi_wdt_ping(struct udevice *dev)
+{
+ struct sunxi_wdt_priv *sunxi_wdt = dev_get_priv(dev);
+ void __iomem *wdt_base = sunxi_wdt->wdt_base;
+ const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs;
+
+ writel(WDT_CTRL_RELOAD, wdt_base + regs->wdt_ctrl);
+
+ return 0;
+}
+
+static int sunxi_wdt_set_timeout(struct udevice *dev,
+ unsigned int timeout)
+{
+ struct sunxi_wdt_priv *sunxi_wdt = dev_get_priv(dev);
+ void __iomem *wdt_base = sunxi_wdt->wdt_base;
+ const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs;
+ u32 reg;
+
+ if (wdt_timeout_map[timeout] == 0)
+ timeout++;
+
+ sunxi_wdt->timeout = timeout;
+
+ reg = readl(wdt_base + regs->wdt_mode);
+ reg &= ~(WDT_TIMEOUT_MASK << regs->wdt_timeout_shift);
+ reg |= wdt_timeout_map[timeout] << regs->wdt_timeout_shift;
+ writel(reg, wdt_base + regs->wdt_mode);
+
+ sunxi_wdt_ping(dev);
+
+ return 0;
+}
+
+static int sunxi_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
+{
+ u32 reg;
+ struct sunxi_wdt_priv *sunxi_wdt = dev_get_priv(dev);
+ void __iomem *wdt_base = sunxi_wdt->wdt_base;
+ const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs;
+ int ret;
+ u64 timeout;
+
+ timeout = timeout_ms / 1000;
+ if (timeout < WDT_MIN_TIMEOUT) {
+ timeout = WDT_MIN_TIMEOUT;
+ } else if (timeout > WDT_MAX_TIMEOUT) {
+ timeout = WDT_MAX_TIMEOUT;
+ }
+
+ ret = sunxi_wdt_set_timeout(dev, (u32) timeout);
+ if (ret < 0)
+ return ret;
+
+ /* Set system reset function */
+ reg = readl(wdt_base + regs->wdt_cfg);
+ reg &= ~(regs->wdt_reset_mask);
+ reg |= regs->wdt_reset_val;
+ writel(reg, wdt_base + regs->wdt_cfg);
+
+ /* Enable watchdog */
+ reg = readl(wdt_base + regs->wdt_mode);
+ reg |= WDT_MODE_EN;
+ writel(reg, wdt_base + regs->wdt_mode);
+
+ return 0;
+}
+
+static int sunxi_wdt_stop(struct udevice *dev)
+{
+ struct sunxi_wdt_priv *sunxi_wdt = dev_get_priv(dev);
+ void __iomem *wdt_base = sunxi_wdt->wdt_base;
+ const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs;
+
+ writel(0, wdt_base + regs->wdt_mode);
+
+ return 0;
+}
+
+static int sunxi_wdt_restart(struct udevice *dev, ulong flags)
+{
+ struct sunxi_wdt_priv *sunxi_wdt = dev_get_priv(dev);
+ void __iomem *wdt_base = sunxi_wdt->wdt_base;
+ const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs;
+ u32 val;
+
+ /* Set system reset function */
+ val = readl(wdt_base + regs->wdt_cfg);
+ val &= ~(regs->wdt_reset_mask);
+ val |= regs->wdt_reset_val;
+ writel(val, wdt_base + regs->wdt_cfg);
+
+ /* Set lowest timeout and enable watchdog */
+ val = readl(wdt_base + regs->wdt_mode);
+ val &= ~(WDT_TIMEOUT_MASK << regs->wdt_timeout_shift);
+ val |= WDT_MODE_EN;
+ writel(val, wdt_base + regs->wdt_mode);
+
+ /*
+ * Restart the watchdog. The default (and lowest) interval
+ * value for the watchdog is 0.5s.
+ */
+ writel(WDT_CTRL_RELOAD, wdt_base + regs->wdt_ctrl);
+
+ while (1) {
+ mdelay(5);
+ val = readl(wdt_base + regs->wdt_mode);
+ val |= WDT_MODE_EN;
+ writel(val, wdt_base + regs->wdt_mode);
+ }
+ return 0;
+}
+
+static const struct wdt_ops sunxi_wdt_ops = {
+ .start = sunxi_wdt_start,
+ .stop = sunxi_wdt_stop,
+ .reset = sunxi_wdt_ping,
+ .expire_now = sunxi_wdt_restart,
+};
+
+static const struct sunxi_wdt_reg sun4i_wdt_reg = {
+ .wdt_ctrl = 0x00,
+ .wdt_cfg = 0x04,
+ .wdt_mode = 0x04,
+ .wdt_timeout_shift = 3,
+ .wdt_reset_mask = 0x02,
+ .wdt_reset_val = 0x02,
+};
+
+static const struct sunxi_wdt_reg sun6i_wdt_reg = {
+ .wdt_ctrl = 0x10,
+ .wdt_cfg = 0x14,
+ .wdt_mode = 0x18,
+ .wdt_timeout_shift = 4,
+ .wdt_reset_mask = 0x03,
+ .wdt_reset_val = 0x01,
+};
+
+static const struct udevice_id sunxi_wdt_ids[] = {
+ { .compatible = "allwinner,sun4i-a10-wdt", .data = (ulong)&sun4i_wdt_reg },
+ { .compatible = "allwinner,sun6i-a31-wdt", .data = (ulong)&sun6i_wdt_reg },
+ { /* sentinel */ }
+};
+
+static int sunxi_wdt_probe(struct udevice *dev)
+{
+ struct sunxi_wdt_priv *sunxi_wdt = dev_get_priv(dev);
+ fdt_addr_t addr;
+ fdt_size_t size;
+
+ addr = devfdt_get_addr_size_index(dev, 0, &size);
+ if (addr == FDT_ADDR_T_NONE)
+ return -EINVAL;
+
+ sunxi_wdt->wdt_regs = (void *)dev_get_driver_data(dev);
+ sunxi_wdt->timeout = WDT_MAX_TIMEOUT;
+
+ sunxi_wdt_stop(dev);
+
+ debug("Watchdog probed (timeout=%d sec)\n", sunxi_wdt->timeout);
+
+ return 0;
+}
+
+static inline bool save_reg_from_ofdata(struct udevice *dev, int index, void __iomem **reg)
+{
+ fdt_addr_t addr;
+ fdt_size_t off;
+
+ addr = fdtdec_get_addr_size_auto_noparent(
+ gd->fdt_blob, dev_of_offset(dev), "reg", index, &off, true);
+
+ if (addr == FDT_ADDR_T_NONE)
+ return false;
+
+ *reg = (void __iomem *) addr;
+
+ return true;
+}
+
+static int sunxi_wdt_ofdata_to_platdata(struct udevice *dev)
+{
+ struct sunxi_wdt_priv *priv = dev_get_priv(dev);
+
+ if (!save_reg_from_ofdata(dev, 0, &priv->wdt_base)) {
+ debug("%s: Could not determine Sunxi wdt IO address\n", __func__);
+ return -ENXIO;
+ }
+
+ return 0;
+}
+
+U_BOOT_DRIVER(sunxi_wdt) = {
+ .name = "sunxi_wdt",
+ .id = UCLASS_WDT,
+ .of_match = sunxi_wdt_ids,
+ .probe = sunxi_wdt_probe,
+ .ops = &sunxi_wdt_ops,
+ .priv_auto_alloc_size = sizeof(struct sunxi_wdt_priv),
+ .ofdata_to_platdata = sunxi_wdt_ofdata_to_platdata,
+};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment