From 751424392b47bddda398a14ebc5cde25ba3fee11 Mon Sep 17 00:00:00 2001 From: AI Dev Date: Wed, 14 Oct 2026 14:12:48 +0000 Subject: [PATCH 1/2] lite <-> ultimate without a UART: sysupgrade on the 16 MB layout, ipctool on the 8 MB one A page, in English and Russian, for moving a 16 MB NOR camera between lite and ultimate and back over the network, keeping its settings. What to do depends on the flash layout the camera already has, read off /proc/mtd: - 16 MB layout: sysupgrade --url with the other variant. --force_ver is needed because a night's lite and ultimate carry the same version, and without it sysupgrade writes nothing. A device profile also needs --force_soc. - 8 MB layout on a 16 MB chip: ipctool upgrade with a --layout bundle, which repartitions in place, keeps the bootloader and carries the settings. Also covers a full-flash backup taken first, a rehearsal of the whole move on that backup in qemu-hisilicon, what ipctool refuses before touching anything, going back to lite, and what to send when something goes wrong. --- README.md | 2 + en/lite-ultimate-migration.md | 251 ++++++++++++++++++++++++++++++++++ ru/lite-ultimate-migration.md | 249 +++++++++++++++++++++++++++++++++ 3 files changed, 502 insertions(+) create mode 100644 en/lite-ultimate-migration.md create mode 100644 ru/lite-ultimate-migration.md diff --git a/README.md b/README.md index 94828050..1cd05f92 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ OpenIPC Wiki - [Two cameras, one scene: the other camera's picture on this one](en/two-cameras-one-scene.md) - [Factory reset and the unclaimed camera](en/first-boot.md) - [Upgrade firmware](en/sysupgrade.md) +- [Moving between lite and ultimate without a UART](en/lite-ultimate-migration.md) - [NAND flash layouts](en/nand-rootfs-layouts.md) - [Failsafe mode and recovery](en/failsafe-recovery.md) - [Nightly builds, dated releases, and bisect](en/nightly-builds-and-bisect.md) @@ -234,6 +235,7 @@ In Russian - [Настройка.](ru/configuration.md) - [Сброс к заводским настройкам и «непринятая» камера](ru/first-boot.md) - [Аварийный режим (failsafe) и восстановление камеры](ru/failsafe-recovery.md) +- [Переход между lite и ultimate без UART](ru/lite-ultimate-migration.md) - [Модернизация адаптера USB2TT_004 для управления питанием.](ru/usb2ttl.md) - [Программный переход с openipc-1.0 (OpenWrt) на openipc-2.x (Buildroot)](ru/upgrade-from-1.md) - [Вопросы и ответы](ru/faq.md) diff --git a/en/lite-ultimate-migration.md b/en/lite-ultimate-migration.md new file mode 100644 index 00000000..388409b0 --- /dev/null +++ b/en/lite-ultimate-migration.md @@ -0,0 +1,251 @@ +# OpenIPC Wiki +[Table of Content](../README.md) + +Moving between lite and ultimate without a UART +----------------------------------------------- + +Ultimate is the bigger firmware: Wi-Fi drivers, ZeroTier, MQTT, the CPU person +detector that object detection and PTZ Follow use on chips without an NPU. It +needs a **16 MB NOR flash**. This page moves a camera from lite to ultimate, and +back, over the network, keeping its settings: passwords, SSH keys, +`majestic.yaml` and everything else under `/overlay`. + +Nothing here needs a serial console. Everything that can go wrong before the +flash is touched is checked first, and the camera refuses rather than starts. +The one thing nothing can protect against is a **power cut while the flash is +being written** (about a minute). Do this on a camera whose power you trust, +and keep the backup below in any case. + +### 1. Find out what you have + +On the camera: + +```console +root@openipc:~# cat /proc/mtd +dev: size erasesize name +mtd0: 00040000 00010000 "boot" +mtd1: 00010000 00010000 "env" +mtd2: 00200000 00010000 "kernel" +mtd3: 00500000 00010000 "rootfs" +mtd4: 008b0000 00010000 "rootfs_data" +``` + +Add up the sizes. `0x1000000` is 16 MB, `0x800000` is 8 MB. On 8 MB, ultimate +does not fit: stop here. The second partition may be called something else +(`wtf` on XiongMai boards); that does not matter. + +Then look at `rootfs`: + +| `rootfs` size | Layout | Go to | +|---|---|---| +| `00a00000` (10 MB) | 16 MB layout, room for ultimate already | [2A](#2a-the-16-mb-layout-sysupgrade) | +| `00500000` (5 MB) on a 16 MB chip | 8 MB layout, from an 8 MB profile or a vendor install | [2B](#2b-the-8-mb-layout-ipctool) | + +`grep BUILD /etc/os-release` tells you which firmware runs now. `BUILD_OPTION` +is `lite` or `ultimate`. A `BUILD_PLATFORM` with two underscores +(`hi3516ev300_lite_xm-85h50ai`) is a **device profile** from +[OpenIPC/builder](https://github.com/OpenIPC/builder). Move it to the same +device's other profile from the builder releases, not to the generic firmware: +the profile carries the board's drivers and settings. + +### 2A. The 16 MB layout: sysupgrade + +No repartition is needed; flash the other variant over this one: + +```console +root@openipc:~# sysupgrade --force_ver \ + --url=https://github.com/OpenIPC/firmware/releases/download/latest/openipc.hi3516ev300-nor-ultimate.tgz +``` + +Use your SoC in the file name, and `-nor-lite.tgz` to go back. + +- `--force_ver` is needed because lite and ultimate from the same night carry + the same version. Without it, sysupgrade prints `Same version, nothing to + update` and reboots having written nothing. +- A device profile also needs `--force_soc`, and its own image: + `https://github.com/OpenIPC/builder/releases/download/latest/_ultimate_-nor.tgz`. + +Settings are kept, as with any sysupgrade. After the reboot, check +`grep BUILD_OPTION /etc/os-release`. + +### 2B. The 8 MB layout: ipctool + +The kernel grows from 2 to 3 MB and the rootfs from 5 to 10 MB, starting at a +new place. `sysupgrade` cannot do that. `ipctool upgrade` can, while the camera +runs: + +- it keeps the bootloader and everything else in front of the kernel exactly as + it is; +- it edits only what has to change in the bootloader's environment: the + partition list and how much kernel to read; +- it copies your settings into the new settings partition. + +#### Back up the whole flash first + +On your computer, with the camera's address and password: + +```console +$ ssh root@192.0.2.10 "cat /dev/mtd0 /dev/mtd1 /dev/mtd2 /dev/mtd3 /dev/mtd4" > camera-backup.bin +$ ls -l camera-backup.bin +-rw-r--r-- 1 user user 16777216 ... camera-backup.bin +``` + +It must be exactly 16777216 bytes. Keep it. It is the whole camera: with it, +anything can be put back, and with it we can reproduce a problem exactly +(see [Something went wrong](#something-went-wrong)). + +It also holds your password hash, Wi-Fi keys and SSH keys, so do not post it +publicly. + +#### Rehearse it on your computer (recommended) + +[qemu-hisilicon](https://github.com/OpenIPC/qemu-hisilicon) runs your +backup as a virtual camera, its own bootloader included. You can do the whole +migration there first and see the result before your real camera is touched. + +This recipe is tested on `hi3516ev300`. The project's README lists the SoCs +whose Linux boots. On a Linux computer: + +```console +$ git clone https://github.com/OpenIPC/qemu-hisilicon && cd qemu-hisilicon +$ bash qemu/setup.sh # builds QEMU, once +$ cp ../camera-backup.bin rehearsal.bin +$ ./qemu-src/build/qemu-system-arm -M hi3516ev300,sensor=none,flash-file=rehearsal.bin \ + -m 128M -nographic -serial file:console.txt -monitor none \ + -nic user,hostfwd=tcp::2222-:22 +``` + +Use your SoC for the machine name. Work on a **copy**: everything the virtual +camera writes goes into that file. + +- After a minute it answers on `ssh -p 2222 root@127.0.0.1` with your camera's + password. +- Run the steps below against it, with `-P 2222` for scp. `console.txt` shows + the boot and the flashing. +- The picture stays black: there is no sensor in the virtual camera, and the + streamer may not start. What the rehearsal proves is the layout, the boot + and the settings. + +#### Make the upgrade bundle + +On your computer, with Python 3: + +```console +$ curl -LO https://raw.githubusercontent.com/OpenIPC/ipctool/master/tools/upgrade_bundle.py +$ curl -LO https://github.com/OpenIPC/firmware/releases/download/latest/openipc.hi3516ev300-nor-ultimate.tgz +$ python3 upgrade_bundle.py --layout nor16m -f openipc.hi3516ev300-nor-ultimate.tgz -o ultimate.bundle +``` + +For a device profile, take its image from the builder releases instead, and +tell the camera where its future upgrades come from: + +```console +$ python3 upgrade_bundle.py --layout nor16m -f hi3516ev300_ultimate_xm-85h50ai-nor.tgz \ + -e upgrade=https://github.com/OpenIPC/builder/releases/download/latest/hi3516ev300_ultimate_xm-85h50ai-nor.tgz \ + -o ultimate.bundle +``` + +The script refuses an image that does not fit its partition. + +#### Copy it and run it + +The bundle is about 10 MB, and the camera writes from it, so it needs that much +room in `/tmp` (`df -h /tmp`). If there is not enough, put it on an SD card +(`/mnt/mmcblk0p1/`). + +```console +$ scp -O ultimate.bundle root@192.0.2.10:/tmp/ +$ ssh root@192.0.2.10 +root@openipc:~# rm -f /tmp/ipctool # so the next line fetches the current release +root@openipc:~# ipctool upgrade /tmp/ultimate.bundle +``` + +`ipctool` is downloaded from GitHub the first time it runs. A camera without +internet access can take it from the +[release page](https://github.com/OpenIPC/ipctool/releases/tag/latest) +(`ipctool` for ARM, `ipctool-mips32`, `ipctool-arm64`), copied to `/tmp` and +made executable. + +Before stopping anything it prints what it will do: + +``` +Keeping boot (256 KB) +Keeping env (64 KB) +Settings: 56 entries in 576 of 2752 KB +bootargs will be: ... mtdparts=hi_sfc:256k(boot),64k(env),3072k(kernel),10240k(rootfs),-(rootfs_data) ... +bootcmd will be: ... sf read ... 0x50000 0x300000 ... +``` + +Then your SSH session drops: every other process is stopped while the flash is +written. The camera reboots by itself, and answers again on its old address with +its old password after about a minute and a half. + +It refuses, with **nothing written** and the camera still running, when: + +| Message | Meaning | +|---|---| +| `image ... doesn't fit to ... partition` | wrong bundle for this layout | +| `the settings need more than ... KB there is room for` | the settings partition is smaller under ultimate (2.7 MB, 8.7 MB under lite). Clean up `/overlay` (old backups, logs), or use `--wipe-settings` | +| `rootfs_data ... is not mounted as jffs2` | the settings cannot be read. `--wipe-settings` goes ahead without them | +| `... has extended attributes, which cannot be carried` | a file in `/overlay` carries one; copying it without would bring back files you deleted | +| `The bootloader's environment names no partitions` / `Cannot find root= and mtdparts= ...` | a bootloader this does not know how to edit. Please send us the backup | + +`--wipe-settings` starts the new firmware from defaults. The camera then comes +up **unclaimed**, with no password. Set one in the web interface (see +[Factory reset and the unclaimed camera](first-boot.md)). + +#### Check + +```console +root@openipc:~# cat /proc/mtd +mtd2: 00300000 00010000 "kernel" +mtd3: 00a00000 00010000 "rootfs" +mtd4: 002b0000 00010000 "rootfs_data" +root@openipc:~# grep BUILD_OPTION /etc/os-release +BUILD_OPTION=ultimate +``` + +From now on the camera upgrades like any other 16 MB-layout camera: +`sysupgrade -k -r`, or the web interface. + +### Back to lite + +**On the 16 MB layout** (where 2B left you): use 2A with the lite image. Lite +runs fine in the bigger partitions. + +**To return to the 8 MB layout exactly**, for instance a device profile that +only exists in lite, use 2B with `--layout nor8m` and the lite image: + +```console +$ python3 upgrade_bundle.py --layout nor8m -f openipc.hi3516ev300-nor-lite.tgz -o lite.bundle +``` + +The settings partition grows back to 8.7 MB, so the settings always fit. + +### Something went wrong + +- **The camera did not come back.** If it rebooted into a broken state, it + needs a UART (or a programmer) and your backup. +- **Before writing to us**, run the same bundle against your backup in QEMU + (see the rehearsal above). If it fails there too, the problem is reproducible, + and we can fix it from the backup alone. +- Open an issue at [OpenIPC/ipctool](https://github.com/OpenIPC/ipctool/issues) + with: + - what `ipctool upgrade` printed; + - `cat /proc/mtd` and `fw_printenv` from before; + - the bundle's file name. + + Send the backup itself **privately**, not attached to the issue: it contains + your passwords and keys. + +### Tested + +- **8 MB layout, vendor bootloader:** a XiongMai 85H50AI (hi3516ev300, 16 MB + NOR, XiongMai bootloader). Rehearsed in QEMU on its own flash dump, then on + the camera itself. Settings carried: every file under `/overlay` was + byte-identical afterwards, except the clock and random-seed files the + firmware rewrites on every boot. +- **8 MB layout, OpenIPC bootloader:** in QEMU, a hi3516ev300 on OpenIPC's own + bootloader, from the 16 MB layout to the 8 MB one (lite) and back (ultimate). +- **16 MB layout:** in QEMU, a hi3516ev300 on the generic firmware, sysupgraded + to lite and back to ultimate. diff --git a/ru/lite-ultimate-migration.md b/ru/lite-ultimate-migration.md new file mode 100644 index 00000000..65268748 --- /dev/null +++ b/ru/lite-ultimate-migration.md @@ -0,0 +1,249 @@ +# OpenIPC Wiki +[Оглавление](../README.md) + +Переход между lite и ultimate без UART +-------------------------------------- + +Ultimate — расширенная прошивка: драйверы Wi-Fi, ZeroTier, MQTT и детектор +людей на процессоре. Им пользуются распознавание объектов и следование PTZ на +чипах без NPU. Ей нужна **NOR-флешка на 16 МБ**. Здесь описано, как перевести +камеру с lite на ultimate и обратно по сети, сохранив настройки: пароли, +SSH-ключи, `majestic.yaml` и всё остальное в `/overlay`. + +Последовательная консоль не нужна. Всё, что может помешать, проверяется до +того, как будет тронута флешка, и при проблеме камера отказывается начинать. +Защиты нет только от **пропадания питания во время записи флешки** (около +минуты). Делайте это на камере с надёжным питанием, и в любом случае сначала +сделайте резервную копию, как описано ниже. + +### 1. Что у вас сейчас + +На камере: + +```console +root@openipc:~# cat /proc/mtd +dev: size erasesize name +mtd0: 00040000 00010000 "boot" +mtd1: 00010000 00010000 "env" +mtd2: 00200000 00010000 "kernel" +mtd3: 00500000 00010000 "rootfs" +mtd4: 008b0000 00010000 "rootfs_data" +``` + +Сложите размеры: `0x1000000` — это 16 МБ, `0x800000` — 8 МБ. На 8 МБ ultimate +не помещается, дальше читать не нужно. Второй раздел может называться иначе +(`wtf` на платах XiongMai), это не важно. + +Теперь посмотрите на `rootfs`: + +| Размер `rootfs` | Разметка | Куда дальше | +|---|---|---| +| `00a00000` (10 МБ) | разметка 16 МБ, место под ultimate уже есть | [2A](#2a-разметка-16-мб-sysupgrade) | +| `00500000` (5 МБ) на чипе 16 МБ | разметка 8 МБ, от профиля на 8 МБ или вендорской установки | [2B](#2b-разметка-8-мб-ipctool) | + +`grep BUILD /etc/os-release` покажет, что за прошивка стоит сейчас. +`BUILD_OPTION` — это `lite` или `ultimate`. `BUILD_PLATFORM` с двумя +подчёркиваниями (`hi3516ev300_lite_xm-85h50ai`) означает **профиль устройства** +из [OpenIPC/builder](https://github.com/OpenIPC/builder). Переводите его на +другой профиль того же устройства из релизов builder, а не на общую прошивку: +в профиле драйверы и настройки этой платы. + +### 2A. Разметка 16 МБ: sysupgrade + +Переразметка не нужна, просто прошейте другой вариант поверх: + +```console +root@openipc:~# sysupgrade --force_ver \ + --url=https://github.com/OpenIPC/firmware/releases/download/latest/openipc.hi3516ev300-nor-ultimate.tgz +``` + +Подставьте свой SoC в имя файла. Для возврата используйте `-nor-lite.tgz`. + +- `--force_ver` нужен, потому что ночные сборки lite и ultimate имеют одну и ту + же версию. Без него sysupgrade напишет `Same version, nothing to update` и + перезагрузится, ничего не записав. +- Профилю устройства нужен ещё и `--force_soc`, а также его собственный образ: + `https://github.com/OpenIPC/builder/releases/download/latest/_ultimate_<устройство>-nor.tgz`. + +Настройки сохраняются, как при любом sysupgrade. После перезагрузки проверьте +`grep BUILD_OPTION /etc/os-release`. + +### 2B. Разметка 8 МБ: ipctool + +Ядро вырастает с 2 до 3 МБ, rootfs — с 5 до 10 МБ и начинается в другом месте. +`sysupgrade` так не умеет. `ipctool upgrade` умеет, и прямо на работающей +камере: + +- загрузчик и всё, что лежит перед ядром, остаётся как было; +- в окружении загрузчика правится только необходимое: список разделов и сколько + читать ядра; +- настройки переносятся в новый раздел. + +#### Сначала резервная копия всей флешки + +На компьютере, подставив адрес и пароль камеры: + +```console +$ ssh root@192.0.2.10 "cat /dev/mtd0 /dev/mtd1 /dev/mtd2 /dev/mtd3 /dev/mtd4" > camera-backup.bin +$ ls -l camera-backup.bin +-rw-r--r-- 1 user user 16777216 ... camera-backup.bin +``` + +Размер должен быть ровно 16777216 байт. Сохраните этот файл. В нём вся камера: +по нему можно вернуть что угодно, а мы можем в точности воспроизвести проблему +(см. [Если что-то пошло не так](#если-что-то-пошло-не-так)). + +В нём же лежат хэш вашего пароля, ключи Wi-Fi и SSH, так что не выкладывайте +его публично. + +#### Репетиция на компьютере (рекомендуется) + +[qemu-hisilicon](https://github.com/OpenIPC/qemu-hisilicon) запускает вашу +копию как виртуальную камеру, вместе с её загрузчиком. Можно сначала проделать +весь переход там и увидеть результат, не трогая настоящую камеру. + +Рецепт проверен на `hi3516ev300`. В README проекта указано, на каких SoC +загружается Linux. На компьютере с Linux: + +```console +$ git clone https://github.com/OpenIPC/qemu-hisilicon && cd qemu-hisilicon +$ bash qemu/setup.sh # сборка QEMU, один раз +$ cp ../camera-backup.bin rehearsal.bin +$ ./qemu-src/build/qemu-system-arm -M hi3516ev300,sensor=none,flash-file=rehearsal.bin \ + -m 128M -nographic -serial file:console.txt -monitor none \ + -nic user,hostfwd=tcp::2222-:22 +``` + +В имени машины укажите свой SoC. Работайте с **копией**: всё, что пишет +виртуальная камера, попадает в этот файл. + +- Через минуту она отвечает на `ssh -p 2222 root@127.0.0.1` с паролем вашей + камеры. +- Проделайте с ней шаги ниже, с `-P 2222` для scp. В `console.txt` видны + загрузка и прошивка. +- Картинки не будет: сенсора у виртуальной камеры нет, и стример может не + запуститься. Репетиция проверяет разметку, загрузку и настройки. + +#### Соберите пакет обновления + +На компьютере, нужен Python 3: + +```console +$ curl -LO https://raw.githubusercontent.com/OpenIPC/ipctool/master/tools/upgrade_bundle.py +$ curl -LO https://github.com/OpenIPC/firmware/releases/download/latest/openipc.hi3516ev300-nor-ultimate.tgz +$ python3 upgrade_bundle.py --layout nor16m -f openipc.hi3516ev300-nor-ultimate.tgz -o ultimate.bundle +``` + +Для профиля устройства возьмите образ из релизов builder и укажите камере, +откуда брать будущие обновления: + +```console +$ python3 upgrade_bundle.py --layout nor16m -f hi3516ev300_ultimate_xm-85h50ai-nor.tgz \ + -e upgrade=https://github.com/OpenIPC/builder/releases/download/latest/hi3516ev300_ultimate_xm-85h50ai-nor.tgz \ + -o ultimate.bundle +``` + +Если образ не помещается в свой раздел, скрипт откажется его собирать. + +#### Скопируйте и запустите + +Пакет весит около 10 МБ, и камера пишет прямо из него, так что в `/tmp` нужно +столько же свободного места (`df -h /tmp`). Если не хватает, положите его на +SD-карту (`/mnt/mmcblk0p1/`). + +```console +$ scp -O ultimate.bundle root@192.0.2.10:/tmp/ +$ ssh root@192.0.2.10 +root@openipc:~# rm -f /tmp/ipctool # чтобы следующая команда скачала свежий релиз +root@openipc:~# ipctool upgrade /tmp/ultimate.bundle +``` + +`ipctool` скачивается с GitHub при первом запуске. Камере без интернета его +можно взять со +[страницы релиза](https://github.com/OpenIPC/ipctool/releases/tag/latest) +(`ipctool` для ARM, `ipctool-mips32`, `ipctool-arm64`): скопировать в `/tmp` +и сделать исполняемым. + +Прежде чем что-то останавливать, он показывает, что собирается сделать: + +``` +Keeping boot (256 KB) +Keeping env (64 KB) +Settings: 56 entries in 576 of 2752 KB +bootargs will be: ... mtdparts=hi_sfc:256k(boot),64k(env),3072k(kernel),10240k(rootfs),-(rootfs_data) ... +bootcmd will be: ... sf read ... 0x50000 0x300000 ... +``` + +Потом SSH-сессия обрывается: на время записи флешки останавливаются все +остальные процессы. Камера перезагрузится сама и примерно через полторы минуты +снова ответит по старому адресу со старым паролем. + +Она откажется, **ничего не записав** и продолжая работать, если: + +| Сообщение | Что значит | +|---|---| +| `image ... doesn't fit to ... partition` | пакет не для этой разметки | +| `the settings need more than ... KB there is room for` | в ultimate раздел настроек меньше (2,7 МБ против 8,7 МБ в lite). Уберите лишнее из `/overlay` (старые копии, логи) или используйте `--wipe-settings` | +| `rootfs_data ... is not mounted as jffs2` | настройки не прочитать. `--wipe-settings` продолжит без них | +| `... has extended attributes, which cannot be carried` | у файла в `/overlay` есть расширенный атрибут; без него вернулись бы удалённые вами файлы | +| `The bootloader's environment names no partitions` / `Cannot find root= and mtdparts= ...` | загрузчик, который ipctool не умеет править. Пришлите нам резервную копию | + +С `--wipe-settings` новая прошивка стартует с заводскими настройками. Камера +поднимется **непринятой**, без пароля. Задайте его в веб-интерфейсе (см. +[Сброс к заводским настройкам и «непринятая» камера](first-boot.md)). + +#### Проверьте + +```console +root@openipc:~# cat /proc/mtd +mtd2: 00300000 00010000 "kernel" +mtd3: 00a00000 00010000 "rootfs" +mtd4: 002b0000 00010000 "rootfs_data" +root@openipc:~# grep BUILD_OPTION /etc/os-release +BUILD_OPTION=ultimate +``` + +Дальше камера обновляется как любая камера с разметкой 16 МБ: через +`sysupgrade -k -r` или веб-интерфейс. + +### Обратно на lite + +**На разметке 16 МБ** (на ней вы окажетесь после 2B): сделайте 2A с образом +lite. В больших разделах lite работает без проблем. + +**Чтобы вернуть в точности разметку 8 МБ**, например для профиля устройства, +который есть только в lite: сделайте 2B с `--layout nor8m` и образом lite: + +```console +$ python3 upgrade_bundle.py --layout nor8m -f openipc.hi3516ev300-nor-lite.tgz -o lite.bundle +``` + +Раздел настроек снова вырастает до 8,7 МБ, так что настройки поместятся всегда. + +### Если что-то пошло не так + +- **Камера не вернулась.** Если она перезагрузилась в нерабочем состоянии, + понадобятся UART (или программатор) и ваша резервная копия. +- **Прежде чем писать нам**, прогоните тот же пакет на копии в QEMU (см. + репетицию выше). Если и там не работает, проблема воспроизводится, и мы + сможем исправить её по одной резервной копии. +- Откройте issue в [OpenIPC/ipctool](https://github.com/OpenIPC/ipctool/issues), + приложив: + - что вывел `ipctool upgrade`; + - `cat /proc/mtd` и `fw_printenv` до перехода; + - имя файла пакета. + + Саму копию отправляйте **лично**, не прикладывая к issue: в ней ваши пароли и + ключи. + +### Проверено + +- **Разметка 8 МБ, вендорский загрузчик:** XiongMai 85H50AI (hi3516ev300, + NOR 16 МБ, загрузчик XiongMai). Отрепетировано в QEMU на дампе её же флешки, + затем на самой камере. Настройки перенеслись: все файлы в `/overlay` совпали + побайтно, кроме файлов часов и случайного зерна, которые прошивка + перезаписывает при каждой загрузке. +- **Разметка 8 МБ, загрузчик OpenIPC:** в QEMU, hi3516ev300 с загрузчиком + OpenIPC, с разметки 16 МБ на 8 МБ (lite) и обратно (ultimate). +- **Разметка 16 МБ:** в QEMU, hi3516ev300 на общей прошивке, через sysupgrade на + lite и обратно на ultimate. From 5680f401a8430f111c9fa3e3f194de3fd77af15a Mon Sep 17 00:00:00 2001 From: AI Dev Date: Wed, 14 Oct 2026 14:39:04 +0000 Subject: [PATCH 2/2] lite-ultimate: back up every partition, keep the upgrade address with the variant Three findings from review, in both languages: - The backup named five mtd devices, so a camera with another partition table got a short file and failed the size check the page asks for. It now reads every partition /proc/mtd lists, in order, as the backup page does. - The upgrade address survives a move. One that names the variant being left would bring it back on the next sysupgrade -k -r. The page now has the reader check fw_printenv upgrade and replace the address with -e when it is set, or with fw_setenv after a profile's sysupgrade. - Going back to lite showed the generic image even where it offered the route to device profiles, which need their own builder lite image. --- en/lite-ultimate-migration.md | 40 +++++++++++++++++++++++++++++----- ru/lite-ultimate-migration.md | 41 ++++++++++++++++++++++++++++++----- 2 files changed, 69 insertions(+), 12 deletions(-) diff --git a/en/lite-ultimate-migration.md b/en/lite-ultimate-migration.md index 388409b0..d2a22ba6 100644 --- a/en/lite-ultimate-migration.md +++ b/en/lite-ultimate-migration.md @@ -64,6 +64,9 @@ Use your SoC in the file name, and `-nor-lite.tgz` to go back. update` and reboots having written nothing. - A device profile also needs `--force_soc`, and its own image: `https://github.com/OpenIPC/builder/releases/download/latest/_ultimate_-nor.tgz`. + Its settings are kept, and with them the address the profile set for future + upgrades, which still names the old variant. Point it at the new one: + `fw_setenv upgrade `. Settings are kept, as with any sysupgrade. After the reboot, check `grep BUILD_OPTION /etc/os-release`. @@ -85,12 +88,14 @@ runs: On your computer, with the camera's address and password: ```console -$ ssh root@192.0.2.10 "cat /dev/mtd0 /dev/mtd1 /dev/mtd2 /dev/mtd3 /dev/mtd4" > camera-backup.bin +$ ssh root@192.0.2.10 'for m in $(sed -n "s/^mtd\([0-9]*\):.*/\1/p" /proc/mtd); do cat /dev/mtdblock$m; done' > camera-backup.bin $ ls -l camera-backup.bin -rw-r--r-- 1 user user 16777216 ... camera-backup.bin ``` -It must be exactly 16777216 bytes. Keep it. It is the whole camera: with it, +That reads every partition `/proc/mtd` lists, in its order, which is the +order on the chip ([Backing up firmware](backup-stock-firmware.md) explains +why a shell glob would not do). It must come to exactly 16777216 bytes. Keep it. It is the whole camera: with it, anything can be put back, and with it we can reproduce a problem exactly (see [Something went wrong](#something-went-wrong)). @@ -136,8 +141,18 @@ $ curl -LO https://github.com/OpenIPC/firmware/releases/download/latest/openipc. $ python3 upgrade_bundle.py --layout nor16m -f openipc.hi3516ev300-nor-ultimate.tgz -o ultimate.bundle ``` -For a device profile, take its image from the builder releases instead, and -tell the camera where its future upgrades come from: +See where the camera takes its upgrades from now: + +```console +root@openipc:~# fw_printenv upgrade +``` + +If that prints nothing (`## Error: "upgrade" not defined`), the camera finds its +upgrades from the firmware it runs, and the bundle above is all you need. If +it prints an address, it names the variant you are leaving, and the bundle has +to replace it, or the next `sysupgrade -k -r` would bring that variant back. +A device profile always has one. Take its image from the builder releases, and +give the new address with `-e`: ```console $ python3 upgrade_bundle.py --layout nor16m -f hi3516ev300_ultimate_xm-85h50ai-nor.tgz \ @@ -213,13 +228,26 @@ From now on the camera upgrades like any other 16 MB-layout camera: **On the 16 MB layout** (where 2B left you): use 2A with the lite image. Lite runs fine in the bigger partitions. -**To return to the 8 MB layout exactly**, for instance a device profile that -only exists in lite, use 2B with `--layout nor8m` and the lite image: +**To return to the 8 MB layout exactly**, use 2B with `--layout nor8m` and +the lite image. For a camera on the generic firmware: ```console $ python3 upgrade_bundle.py --layout nor8m -f openipc.hi3516ev300-nor-lite.tgz -o lite.bundle ``` +For a device profile, its own lite image from the builder releases, with the +address set back to it. The generic image would drop the profile's drivers and +settings for the board: + +```console +$ python3 upgrade_bundle.py --layout nor8m -f hi3516ev300_lite_xm-85h50ai-nor.tgz \ + -e upgrade=https://github.com/OpenIPC/builder/releases/download/latest/hi3516ev300_lite_xm-85h50ai-nor.tgz \ + -o lite.bundle +``` + +As on the way there, check `fw_printenv upgrade` first. If it names an address +on a generic camera, pass the lite one with `-e`. + The settings partition grows back to 8.7 MB, so the settings always fit. ### Something went wrong diff --git a/ru/lite-ultimate-migration.md b/ru/lite-ultimate-migration.md index 65268748..051e3e8f 100644 --- a/ru/lite-ultimate-migration.md +++ b/ru/lite-ultimate-migration.md @@ -64,6 +64,9 @@ root@openipc:~# sysupgrade --force_ver \ перезагрузится, ничего не записав. - Профилю устройства нужен ещё и `--force_soc`, а также его собственный образ: `https://github.com/OpenIPC/builder/releases/download/latest/_ultimate_<устройство>-nor.tgz`. + Настройки сохраняются, а с ними и заданный профилем адрес будущих обновлений, + который по-прежнему указывает на старый вариант. Перенаправьте его на новый: + `fw_setenv upgrade `. Настройки сохраняются, как при любом sysupgrade. После перезагрузки проверьте `grep BUILD_OPTION /etc/os-release`. @@ -84,12 +87,15 @@ root@openipc:~# sysupgrade --force_ver \ На компьютере, подставив адрес и пароль камеры: ```console -$ ssh root@192.0.2.10 "cat /dev/mtd0 /dev/mtd1 /dev/mtd2 /dev/mtd3 /dev/mtd4" > camera-backup.bin +$ ssh root@192.0.2.10 'for m in $(sed -n "s/^mtd\([0-9]*\):.*/\1/p" /proc/mtd); do cat /dev/mtdblock$m; done' > camera-backup.bin $ ls -l camera-backup.bin -rw-r--r-- 1 user user 16777216 ... camera-backup.bin ``` -Размер должен быть ровно 16777216 байт. Сохраните этот файл. В нём вся камера: +Команда читает все разделы из `/proc/mtd` в том порядке, в каком они лежат на +чипе (почему не подойдёт маска оболочки, объяснено в +[Backing up firmware](../en/backup-stock-firmware.md)). Размер должен быть +ровно 16777216 байт. Сохраните этот файл. В нём вся камера: по нему можно вернуть что угодно, а мы можем в точности воспроизвести проблему (см. [Если что-то пошло не так](#если-что-то-пошло-не-так)). @@ -134,8 +140,18 @@ $ curl -LO https://github.com/OpenIPC/firmware/releases/download/latest/openipc. $ python3 upgrade_bundle.py --layout nor16m -f openipc.hi3516ev300-nor-ultimate.tgz -o ultimate.bundle ``` -Для профиля устройства возьмите образ из релизов builder и укажите камере, -откуда брать будущие обновления: +Посмотрите, откуда камера сейчас берёт обновления: + +```console +root@openipc:~# fw_printenv upgrade +``` + +Если ничего не выведено (`## Error: "upgrade" not defined`), камера определяет +источник обновлений по самой прошивке, и пакета выше достаточно. Если выведен +адрес, он указывает на вариант, с которого вы уходите, и пакет должен его +заменить, иначе следующий `sysupgrade -k -r` вернёт старый вариант. У профиля +устройства этот адрес есть всегда. Возьмите его образ из релизов builder и +передайте новый адрес через `-e`: ```console $ python3 upgrade_bundle.py --layout nor16m -f hi3516ev300_ultimate_xm-85h50ai-nor.tgz \ @@ -211,13 +227,26 @@ BUILD_OPTION=ultimate **На разметке 16 МБ** (на ней вы окажетесь после 2B): сделайте 2A с образом lite. В больших разделах lite работает без проблем. -**Чтобы вернуть в точности разметку 8 МБ**, например для профиля устройства, -который есть только в lite: сделайте 2B с `--layout nor8m` и образом lite: +**Чтобы вернуть в точности разметку 8 МБ**, сделайте 2B с `--layout nor8m` и +образом lite. Для камеры на общей прошивке: ```console $ python3 upgrade_bundle.py --layout nor8m -f openipc.hi3516ev300-nor-lite.tgz -o lite.bundle ``` +Для профиля устройства нужен его собственный образ lite из релизов builder, +и адрес обновлений надо вернуть на него. Общий образ лишил бы плату драйверов +и настроек профиля: + +```console +$ python3 upgrade_bundle.py --layout nor8m -f hi3516ev300_lite_xm-85h50ai-nor.tgz \ + -e upgrade=https://github.com/OpenIPC/builder/releases/download/latest/hi3516ev300_lite_xm-85h50ai-nor.tgz \ + -o lite.bundle +``` + +Как и по пути туда, сначала проверьте `fw_printenv upgrade`. Если на общей +камере там указан адрес, передайте через `-e` адрес lite. + Раздел настроек снова вырастает до 8,7 МБ, так что настройки поместятся всегда. ### Если что-то пошло не так