Repository navigation
upgrade: move cameras on OpenIPC's own bootloader, in the memory they have - #248
Conversation
… have
Run against a camera on OpenIPC's bootloader rather than a vendor one, the
layout move refused, and on a lite image it would not have fitted in memory
anyway:
- OpenIPC's bootcmd reads the kernel to a variable,
"sf read ${baseaddr} 0x50000 0x200000". The edit required a number for
the address and refused. The address may now be any word; only the
offset and the size change.
- Its default bootargs say mtdparts=${mtdparts}. That word is now left as
it is, and the mtdparts variable is set instead, its mtd id read from
it. A literal mtdparts= is still edited in place, and the variable,
where there is one, follows either way.
- bootcmdnor, the copy of the kernel read that its setnor8m/setnor16m and
failsafe run, gets the same edit. A bundle may not set it or mtdparts.
- Each image was copied into a buffer the size of its partition: 13 MB
for an ultimate bundle, on top of the bundle itself, which already sits
in RAM when it is in /tmp. A lite camera booted with mem=32M has about
16 MB. Images are now written from the mapped bundle, and the end of
each is padded in one erase block. The settings partition keeps only
the carried image, not 2.7 MB of 0xFF.
QEMU (hi3516ev300) with the openipc.org 16 MB full image, OpenIPC's
bootloader, and a saved environment in the shape it keeps
(mtdparts=${mtdparts}, sf read ${baseaddr}):
- generic lite moved from the 16 MB layout to the 8 MB one;
- then generic ultimate moved back to the 16 MB layout;
- the carried settings survived both moves;
- mtdparts, bootcmd and bootcmdnor followed each time.
|
/review |
Code Review by Qodo
1.
|
Four findings from review:
- A bootcmdnor with a kernel read that could not be edited was left as
it was, so failsafe and setnor8m/16m would have read the old kernel's
place. A copy with no read is still left alone. One whose read cannot
be edited, more than one read, or an edit that does not fit its buffer
(which used to be saved truncated) is now refused before anything is
stopped, like bootcmd.
- bootargs naming any variable as mtdparts= was taken as a reference to
the mtdparts variable, which is the only one upgrade sets. A
${mtdpartsnor} would have moved root= and left the kernel the old
partitions. Only ${mtdparts} and $mtdparts count now; any other
reference is neither literal nor followable, and is refused.
- With --wipe-settings, the settings partition has no data, and each
block formed an offset from a null pointer before the padding buffer
was chosen. The pointer is now formed only where there are bytes
behind it.
QEMU (hi3516ev300):
- --wipe-settings on OpenIPC's bootloader moved to the 8 MB layout and
booted, with the kernel formatting the fresh settings partition;
- the XiongMai camera's move to ultimate still carries every setting.
Follow-up to #247. That PR was tested against a vendor (XiongMai) bootloader, whose environment is fully literal. A camera on OpenIPC's own bootloader would have been refused, and on a lite image the move would not have fitted in memory anyway.
OpenIPC's bootloader environment
bootcmdreads the kernel to a variable:sf read ${baseaddr} 0x50000 0x200000. The address may now be any word; only the offset and size are edited.bootargssaymtdparts=${mtdparts}. That word is left alone, and themtdpartsvariable is set instead, with its mtd id read from the variable. A literalmtdparts=is still edited in place, and the variable, if present, follows either way.bootcmdnor, whichsetnor8m/setnor16mand failsafe run, gets the same edit. A bundle may not setbootcmdnorormtdparts;upgrade_bundle.pyrefuses them as-etoo.Memory
Each image used to be copied into a buffer the size of its partition. For an ultimate bundle that is 13 MB, on top of the bundle itself, which already sits in RAM when it is in
/tmp. A lite camera booted withmem=32Mhas about 16 MB available.Images are now written straight from the mapped bundle, and the end of each one is padded in a single erase-block buffer. The settings partition likewise keeps only the carried image, not 2.7 MB of
0xFF.Tested on QEMU (hi3516ev300)
OpenIPC's bootloader: the openipc.org 16 MB full image, plus a saved environment in the shape OpenIPC keeps (
mtdparts=${mtdparts},sf read ${baseaddr}):mtdparts,bootcmdandbootcmdnorfollowed each time.XiongMai bootloader (the #247 case), re-run with this change:
0xFF.upgrade_env_testcovers the variable load address,mtdparts=${mtdparts}, and reading the mtd id from the variable.