Add support for Beeline SmartBox TURBO+

Layout dual-flag (Boot Flag) - mtd3

boot_flag indicates which slot to load.
boot_count counts the number of times one slot is started.

Slot Flag kernel rootfs Counter
1 Sercomm0 uImage1 (Kernel 1) rootfs1 (File System 1) boot_count1
2 Sercomm1 uImage2 (Kernel 2) rootfs2 (File System 2) boot_count2

When the U-boot of the specified slot is loaded, its counter is incremented (example FF-> 01). When the stock firmware boots successfully, it will write to the FF counter. If the boot_count = 03 when loading the slot, then the flag will be toggled. if boot_count1 = 03 and boot_count2 = 03 then the device will switch to Emergency mode (start sc_dl).

View flag:
# hexdump -Cn 8 /dev/mtd3                                                       
00000000  53 65 72 63 6f 6d 6d 31                           |Sercomm1|          
00000008  
Set flag:
  • Sercomm0 - # printf 0 | dd bs=1 seek=7 count=1 of=/dev/mtdblock3
  • Sercomm1 - # printf 1 | dd bs=1 seek=7 count=1 of=/dev/mtdblock3
FW OEM v2.0.xx
~ # bootflag_utility --help
bootflag_utility: invalid option -- -
Usage: ./bootflag_utility [-g] [-s value] [-S]
-g get bootflag
-s set bootflag 0 or 1
-S switch bootflag
View flag:
# bootflag_utility -g    
[bootflag_utility.c:get_bootflag:52] bootflag=Sercomm0
get_bootflag=0
Set flag:
  • Sercomm0 - # bootflag_utility -s 0
  • Sercomm1 - # bootflag_utility -s 1
View counter

$((0x20001))=131073

  • boot_count1 - # hexdump -s 131073 -Cn 1 /dev/mtd3
  • boot_count2 - # hexdump -s 131074 -Cn 1 /dev/mtd3
# hexdump -s 131073 -Cn 2 /dev/mtd3                                             
00020001  ff ff                                             |..|                
00020003
Reset counter
  • boot_count1 - # printf '\xFF' | dd bs=1 count=1 seek=131073 of=/dev/mtdblock3
  • boot_count2 - # printf '\xFF' | dd bs=1 count=1 seek=131074 of=/dev/mtdblock3
Algorithm from MTK SDK

Reference

APSoC SDK 4.3.0.0 User’s Manual - 209 Page.

1 Like