Repository navigation
sigmastar: OpenIPC's common layer and openipc-hisilicon's NAND layout - #109
Conversation
common/openipc.c, common/Kconfig and common/Makefile are openipc-ingenic's, which keep openipc-hisilicon's in step and take the SPI NAND path by OPENIPC_SPI_NAND: the split NOR layout (CONFIG_OPENIPC_NOR_SPLIT), the recovery from a FAT partition or a whole-disk FAT, the NAND scan of the UBIFS rootfs and its /boot kernel, the boot-limit failsafe and the saved environment's migrations. OPENIPC_SPI_NAND takes CONFIG_NAND_MS_SPINAND too, and the UBI marker is read from the first good eraseblock, which a corrected read (-EUCLEAN) still gives. CONFIG_OPENIPC_NAND_KERNEL_VOLUME, the kernel in a UBI volume of its own, goes.
768k(boot),256k(env),-(ubi): the environment at 0xC0000 (256 KiB, range 256 KiB), one UBI device from 0x100000 whose UBIFS rootfs volume holds the kernel as /boot/fitImage or /boot/uImage, rootfs_data on the rest, root=ubi0:rootfs rootfstype=ubifs ubi.mtd=2,2048; ur installs rootfs.ubifs.<soc> sized to the image, keeping rootfs_data. nand_config is openipc-hisilicon's, with UBIFS and FIT; the per-die NAND fragments go. The NOR environment takes the split layout's fwupd/fwwrite, fwfile=firmware.bin.<soc>, and mtdslite resetting kernaddr, as the others. Not OpenIPC/u-boot-sigmastar's NAND layout (UBI at 0x240000, a kernel volume and a squashfs rootfs): a camera moving over takes the firmware's rootfs.ubifs too, as HiSilicon's do. qemu: ssc325de, ssc337de, ssc338q from blank through TFTP and SD recovery to login, again after saveenv and reset; ssc377 with mstar-06's Maruko kernel.
One copy of each stage, a block each where the IPL wants blocks: - infinity6, 6b0, 6e, infinity2m: SNI and PNI in block 0 (BL0PBA 1, BL1PBA 0, SNI byte 0x2E 2, where infinity6's IPL_CUST starts its search for U-Boot), IPL in 1, IPL_CUST in 2, U-Boot in 3-5. - infinity6c: the CIS in blocks 0 and 1 (its IPL reads a copy past block 0), IPL in 2, IPL_CUST in 3, U-Boot in 4-5. - Ifliegen: the CIS, IPL, IPL_CUST, TF-A's SP_MIN in blocks 0-3, U-Boot in 4-5. - Iford: its IPL takes every stage by name at any 2 KiB page, which lets the 338 KB OP-TEE in: IPL from 0x20000, IPL_CUST, OP-TEE and U-Boot each from the next page, ending near 0xB8000. NOR and NAND images end where their data does, as OpenIPC's others: no 0xFF padding to the partition. qemu: every image, NOR and NAND, two boots to the autoboot prompt with the environment kept, on its own machine.
…8 KiB boot areas, the common layer
PR Summary by QodoAlign SigmaStar boot and recovery with the OpenIPC NAND layout
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
1.
|
- NOR SD/USB recovery writes only the *.img files whose name carries CONFIG_PRODUCT_SOC as a word between '.' or '-': a card holding several cameras' images flashes this one's alone (uImage.ssc337.img is not ssc337de's). - NAND recovery reads rootfs.ubifs.<soc>.img only if it fits the RAM below the relocated U-Boot, as the NOR image and script.txt paths do. - A saved altbootcmd of the retired form is migrated before recovery, so a script.txt that runs it gets the current one. openipc-sigmastar only for now; the other vendor branches follow. Reported by Qodo on #109.
- The environment is 128 KiB in the 256 KiB env partition: with CONFIG_ENV_SIZE equal to its range, one bad block there left saveenv nowhere to go and every boot on the default environment. - ubwrite writes only an image that fits the 768 KiB boot partition, checked before it erases (a failed write after the erase left no IPL), and into the partition by name, so bad blocks cannot push it into env. The firmware's fw_env.config for these cameras takes the 128 KiB size. qemu ssc337de: an oversize ub refused with the boot intact; the env block at 0xC0000 marked bad, saveenv to 0xE0000, loaded after reset. Reported by Qodo on #109.
This brings openipc-sigmastar in line with the other vendor branches. It follows #107.
Common layer.
common/openipc.c,common/Kconfigand the default environment are now openipc-ingenic's, which follow openipc-hisilicon's. That brings:CONFIG_OPENIPC_NOR_SPLIT);fwfile=firmware.bin.<soc>, and anmtdslitethat resetskernaddr.OPENIPC_SPI_NANDnow includes ourCONFIG_NAND_MS_SPINAND. The UBI marker is read from the first good eraseblock.NOR. The partitions are unchanged:
256k(boot),64k(env). The images now end where their data does; they are no longer padded with0xFFto 256 KiB.SPI NAND, openipc-hisilicon's layout.
768k(boot),256k(env),-(ubi). The environment is at0xC0000: 128 KiB in the 256 KiB partition, so one bad block there doesn't stopsaveenv. openipc-hisilicon uses 256 KiB, so the firmware'sfw_env.configfor these cameras needs the 128 KiB size.rootfsvolume holds the kernel as/boot/fitImageor/boot/uImage, androotfs_datatakes the rest.root=ubi0:rootfs rootfstype=ubifs ubi.mtd=2,2048.ur, orrootfs.ubifs.<soc>.imgon an SD card) installsrootfs.ubifs.<soc>.nand_configis openipc-hisilicon's. The per-die NAND fragments and the separate kernel volume are gone.Each die's vendor boot stages in the 768 KiB boot partition, one copy each:
0x2Etells infinity6's IPL_CUST where to start looking for U-Boot.0xB8000.Ahead of the other vendor branches (from Qodo's review here; they follow later):
ubwritewrites only an image that fits the boot partition. It checks the size before erasing, so a failedrun ubno longer leaves a board with no IPL, and it writes into the partition by name, so a bad block can't push U-Boot intoenv..imgfiles whose name carries this SoC as a word: a card with several cameras' images flashes only this one's. NAND recovery checks that the image fits the free RAM.altbootcmdin the retired form is migrated before recovery runs, so ascript.txtcan't run the old one.Breaking for NAND cameras: this is not OpenIPC/u-boot-sigmastar's NAND layout, which puts UBI at
0x240000with akernelvolume and a squashfsrootfs. A camera moving to this U-Boot needs its NAND firmware packaged asrootfs.ubifs.<soc>, with the kernel in/boot, as HiSilicon's is. That package doesn't exist yet on the OpenIPC/firmware side.Tested, in QEMU only:
rootfs.ubifsover TFTP, and the kernel boots withroot=ubi0:rootfs; again aftersaveenvand reset:ssc325de,ssc337de,ssc338q: tologin:, with their published firmware's kernel and rootfs repacked as UBIFS (kernel in/boot);ssc029a,ssc034a: to the root mount, with SDK kernels;ssd202d: to a shell, with the infinity2m SDK kernel;ssc377: tologin:with an SDK kernel. That kernel has no overlayfs, so the rootfs ends up remounted read-write and is left dirty. The next scan then can't mount it and recovery reinstalls, as HiSilicon's U-Boot would.ssc337dealso installs from an SD card and boots tologin:.Merge this before the CI PR, which needs these 768 KiB NAND images.