[14/15] rockchip: rk3399: Add bootcount support

Message ID 20190729074711.16988-15-jagan@amarulasolutions.com
State New
Headers show
Series
  • rk3399: Add redundant boot support
Related show

Commit Message

Jagan Teki July 29, 2019, 7:47 a.m. UTC
Add bootcount support for Rockchip rk3399.

The bootcount value is preserved in PMU_SYS_REG0 register,
this would help to support redundent boot.

Once the redundant boot triggers, the altboot command
will look for extlinux-rollback.conf on particular
bootable partition which supposed to be a recovery
partition where redundant boot required.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-rockchip/Kconfig        |  2 ++
 arch/arm/mach-rockchip/rk3399/Kconfig | 10 ++++++++++
 include/configs/rk3399_common.h       |  5 ++++-
 3 files changed, 16 insertions(+), 1 deletion(-)

Comments

Kever Yang Aug. 12, 2019, 12:16 p.m. UTC | #1
Hi Jagan,


On 2019/7/29 下午3:47, Jagan Teki wrote:
> Add bootcount support for Rockchip rk3399.
>
> The bootcount value is preserved in PMU_SYS_REG0 register,

PMU_SYS_REG0 has been used by other case in Rockchip, we don't
recommend to use it, the PMUGRF_OS_REG3 is still reserved now,
could you use it instead?

Thanks,
- Kever

> this would help to support redundent boot.
>
> Once the redundant boot triggers, the altboot command
> will look for extlinux-rollback.conf on particular
> bootable partition which supposed to be a recovery
> partition where redundant boot required.
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>   arch/arm/mach-rockchip/Kconfig        |  2 ++
>   arch/arm/mach-rockchip/rk3399/Kconfig | 10 ++++++++++
>   include/configs/rk3399_common.h       |  5 ++++-
>   3 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index 17f31e89f3..dd5055ed69 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -184,6 +184,8 @@ config ROCKCHIP_RK3399
>   	imply TPL_CLK
>   	imply TPL_TINY_MEMSET
>   	imply TPL_ROCKCHIP_COMMON_BOARD
> +	imply SYS_BOOTCOUNT_SINGLEWORD if BOOTCOUNT_LIMIT
> +	imply CMD_BOOTCOUNT if BOOTCOUNT_LIMIT
>   	help
>   	  The Rockchip RK3399 is a ARM-based SoC with a dual-core Cortex-A72
>   	  and quad-core Cortex-A53.
> diff --git a/arch/arm/mach-rockchip/rk3399/Kconfig b/arch/arm/mach-rockchip/rk3399/Kconfig
> index 6660d05349..68ac913bcb 100644
> --- a/arch/arm/mach-rockchip/rk3399/Kconfig
> +++ b/arch/arm/mach-rockchip/rk3399/Kconfig
> @@ -91,6 +91,16 @@ config TPL_STACK
>   config TPL_TEXT_BASE
>           default 0xff8c2000
>   
> +if BOOTCOUNT_LIMIT
> +
> +config BOOTCOUNT_BOOTLIMIT
> +	default 3
> +
> +config SYS_BOOTCOUNT_ADDR
> +	default 0xff3100f0	# PMU_SYS_REG0
> +
> +endif # BOOTCOUNT_LIMIT
> +
>   source "board/rockchip/evb_rk3399/Kconfig"
>   source "board/theobroma-systems/puma_rk3399/Kconfig"
>   source "board/vamrs/rock960_rk3399/Kconfig"
> diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h
> index 67b48e03ba..ace82928d1 100644
> --- a/include/configs/rk3399_common.h
> +++ b/include/configs/rk3399_common.h
> @@ -70,7 +70,10 @@
>   	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
>   	"partitions=" PARTS_DEFAULT \
>   	ROCKCHIP_DEVICE_SETTINGS \
> -	BOOTENV
> +	BOOTENV \
> +	"altbootcmd=" \
> +		"setenv boot_syslinux_conf extlinux/extlinux-rollback.conf;" \
> +		"run distro_bootcmd\0"
>   
>   #endif
>
Kever Yang Aug. 13, 2019, 1:02 a.m. UTC | #2
On 2019/8/12 下午8:16, Kever Yang wrote:
> Hi Jagan,
>
>
> On 2019/7/29 下午3:47, Jagan Teki wrote:
>> Add bootcount support for Rockchip rk3399.
>>
>> The bootcount value is preserved in PMU_SYS_REG0 register,
>
> PMU_SYS_REG0 has been used by other case in Rockchip, we don't


Please ignore this mail, I mixing the registers in PMU and PMUGRF,

the PMU_SYS_REG0 is not used yet and you can use it.


Thanks,

- Kever

> recommend to use it, the PMUGRF_OS_REG3 is still reserved now,
> could you use it instead?
>
> Thanks,
> - Kever
>
>> this would help to support redundent boot.
>>
>> Once the redundant boot triggers, the altboot command
>> will look for extlinux-rollback.conf on particular
>> bootable partition which supposed to be a recovery
>> partition where redundant boot required.
>>
>> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>> ---
>>   arch/arm/mach-rockchip/Kconfig        |  2 ++
>>   arch/arm/mach-rockchip/rk3399/Kconfig | 10 ++++++++++
>>   include/configs/rk3399_common.h       |  5 ++++-
>>   3 files changed, 16 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-rockchip/Kconfig 
>> b/arch/arm/mach-rockchip/Kconfig
>> index 17f31e89f3..dd5055ed69 100644
>> --- a/arch/arm/mach-rockchip/Kconfig
>> +++ b/arch/arm/mach-rockchip/Kconfig
>> @@ -184,6 +184,8 @@ config ROCKCHIP_RK3399
>>       imply TPL_CLK
>>       imply TPL_TINY_MEMSET
>>       imply TPL_ROCKCHIP_COMMON_BOARD
>> +    imply SYS_BOOTCOUNT_SINGLEWORD if BOOTCOUNT_LIMIT
>> +    imply CMD_BOOTCOUNT if BOOTCOUNT_LIMIT
>>       help
>>         The Rockchip RK3399 is a ARM-based SoC with a dual-core 
>> Cortex-A72
>>         and quad-core Cortex-A53.
>> diff --git a/arch/arm/mach-rockchip/rk3399/Kconfig 
>> b/arch/arm/mach-rockchip/rk3399/Kconfig
>> index 6660d05349..68ac913bcb 100644
>> --- a/arch/arm/mach-rockchip/rk3399/Kconfig
>> +++ b/arch/arm/mach-rockchip/rk3399/Kconfig
>> @@ -91,6 +91,16 @@ config TPL_STACK
>>   config TPL_TEXT_BASE
>>           default 0xff8c2000
>>   +if BOOTCOUNT_LIMIT
>> +
>> +config BOOTCOUNT_BOOTLIMIT
>> +    default 3
>> +
>> +config SYS_BOOTCOUNT_ADDR
>> +    default 0xff3100f0    # PMU_SYS_REG0
>> +
>> +endif # BOOTCOUNT_LIMIT
>> +
>>   source "board/rockchip/evb_rk3399/Kconfig"
>>   source "board/theobroma-systems/puma_rk3399/Kconfig"
>>   source "board/vamrs/rock960_rk3399/Kconfig"
>> diff --git a/include/configs/rk3399_common.h 
>> b/include/configs/rk3399_common.h
>> index 67b48e03ba..ace82928d1 100644
>> --- a/include/configs/rk3399_common.h
>> +++ b/include/configs/rk3399_common.h
>> @@ -70,7 +70,10 @@
>>       "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
>>       "partitions=" PARTS_DEFAULT \
>>       ROCKCHIP_DEVICE_SETTINGS \
>> -    BOOTENV
>> +    BOOTENV \
>> +    "altbootcmd=" \
>> +        "setenv boot_syslinux_conf extlinux/extlinux-rollback.conf;" \
>> +        "run distro_bootcmd\0"
>>     #endif
>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot

Patch

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 17f31e89f3..dd5055ed69 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -184,6 +184,8 @@  config ROCKCHIP_RK3399
 	imply TPL_CLK
 	imply TPL_TINY_MEMSET
 	imply TPL_ROCKCHIP_COMMON_BOARD
+	imply SYS_BOOTCOUNT_SINGLEWORD if BOOTCOUNT_LIMIT
+	imply CMD_BOOTCOUNT if BOOTCOUNT_LIMIT
 	help
 	  The Rockchip RK3399 is a ARM-based SoC with a dual-core Cortex-A72
 	  and quad-core Cortex-A53.
diff --git a/arch/arm/mach-rockchip/rk3399/Kconfig b/arch/arm/mach-rockchip/rk3399/Kconfig
index 6660d05349..68ac913bcb 100644
--- a/arch/arm/mach-rockchip/rk3399/Kconfig
+++ b/arch/arm/mach-rockchip/rk3399/Kconfig
@@ -91,6 +91,16 @@  config TPL_STACK
 config TPL_TEXT_BASE
         default 0xff8c2000
 
+if BOOTCOUNT_LIMIT
+
+config BOOTCOUNT_BOOTLIMIT
+	default 3
+
+config SYS_BOOTCOUNT_ADDR
+	default 0xff3100f0	# PMU_SYS_REG0
+
+endif # BOOTCOUNT_LIMIT
+
 source "board/rockchip/evb_rk3399/Kconfig"
 source "board/theobroma-systems/puma_rk3399/Kconfig"
 source "board/vamrs/rock960_rk3399/Kconfig"
diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h
index 67b48e03ba..ace82928d1 100644
--- a/include/configs/rk3399_common.h
+++ b/include/configs/rk3399_common.h
@@ -70,7 +70,10 @@ 
 	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
 	"partitions=" PARTS_DEFAULT \
 	ROCKCHIP_DEVICE_SETTINGS \
-	BOOTENV
+	BOOTENV \
+	"altbootcmd=" \
+		"setenv boot_syslinux_conf extlinux/extlinux-rollback.conf;" \
+		"run distro_bootcmd\0"
 
 #endif