De-brick Device 解砖:指恢复被称为“砖头”的电子设备

Update hard to de-brick devices

解砖:指恢复被称为“砖头”的电子设备(如智能手机、平板电脑等)的正常功能,这些设备由于固件升级失败、操作失误等原因变得无法正常使用。

Solution#1

● Download image to RAM erase / flash
● “Jump in the air and hope for a soft landing”// -.-
● + Fallback (USB recovery)

Solution#2、#3

● Rolling update (pkg based)( 滚动更新 )
– history matters (moved files, postinstall hooks)
– Consistency (一致性)of rootfs state (different upgrade paths,testing)

● Implement(工具) Upgrades in U-Boot
– partition(分区) holds update / u-boot does the flashing
– u-boot env as mailbox, communication rootfs/u-boot
– Out-of-tree u-boot changes?

preinstall:安装前脚本 postinstall :安装后脚本 preuninstall:卸载前脚本 …

in-tree :代码逻辑在 K8s 官方仓库中;

out-of-tree :代码逻辑在 K8s 官方仓库之外,实现与 K8s 代码的解耦;

Bricking the Device

Power fail
External from the update process

More likely the longer the update takes
More likely the more devices in the field(字段)
More likely the more frequent(频繁) the upgrades

Presented Solution

● Rescue(救援 应急系统) System
– Minimal Linux system / ramdisk (initrd)
– Logic to perform upgrades 平台更新的逻辑化
– Safely upgradeable

OneKey Rescue System

RamDisk( 内存盘 )

Demo–boot order

张明星
上次修改于 2023/10/11 16:22:39
image.png

怎么做到rescue每次

Demo–rootfs upgrade

在这里插入图片描述

什么是 kexec?

可从当前正在运行的内核直接跳转到新内核

为什么需要 kexec?

跳过 boot 阶段,减少重启时间

kexec 整体思路如下

1)新的 kernel 镜像和 initrd 镜像连续存储在内存中,initrd 的位置记录在 boot_params 中

2)切换到新内核就是跳转到新的 kernel 镜像所在内存位置,CPU 执行其 entry 的代码即可,新的内核通过 boot_params 记录的 initrd 位置完成根文件系统内容的加载

原理不复杂,但受到一些实际情况的限制,所以在实现上会略复杂一些。

首先,kernel 镜像有指定的入口地址,kernel 镜像要加载到入口地址位置才能正常启动,而这块内存正在被当前内核使用,所以 kernel 镜像需要临时存放的内存,在跳转前要将内容搬移到入口地址。

其次,initrd 的体积可能较大,找不到用于存储 initrd 的连续大段物理内存,因此需要分散存储在能申请到的内存页面中,在 kernel 跳转前搬移拼接到目的地址。

简单讲,镜像先临时存放,切换时再搬移到目标地址。

Why tiny Linux System

POSIX environment
GPG / HTTPS client
Deploy bug fixes / features
(Keyring updates)

Take two legs to walk

image.png

救急系统 ++++++++++急救系统

Unit Tests ——Test run

● Shell scripts
● Mock (模仿 模拟)all used shell tools
● Collect output and compare to good version

Unit Tests - Sysroot

在这里插入图片描述

删除测试的目标文件

增加测试的目标文件

机器文件

公共文件 skeleton 提纲 骨骼

Kernel only upgrades

● Drop In configuration files
– Text file in /boot/entry
– Bundles zImage/dtb/initrd/cmdline
– Signature & Checksum
● [https://freedesktop.org/wiki/Specifications/BootLoaderSpec/](https://freedesktop.org/wiki/Specifications/Boo tLoaderSpec/)
● Could be supported by u-boot as well

Simplified boot-entry

/boot/entries/linux-4.1.19.conf
IMAGE_FILE=zImage-4.1.19
IMAGE_CHECKSUM=53bd741b10c91b04c34cd37d5abae…
DTB_FILE=devicetree-4.1.19-dss11-sdc.dtb
DTB_CHECKSUM=9f26ab6ed73e1f674b68075419cc7e…

/boot/entries/linux-2.6.32-fallback.conf
IMAGE_VOLUME_DEVICE=/dev/mtd4
IMAGE_FORMAT=uImage
ATAGS=true

Roadmap

Preload image into Partition/RAM if space available
Handshake(握手): Rootfs confirms it booted correctly,
detect “bad/corrupted rootfs”
Musl / tiny libc
Mainline patches kexec/linux/yocto
Confirms the password 确认密码

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值