Skip to content

mvebu: add dual-boot support for Fortinet FortiGate/FortiWiFi 30E/5xE devices #16538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

musashino205
Copy link
Contributor

This patch series adds dual-boot support for those devices.

Add fortigate-fw mtdsplit driver to handle dual-boot by splitting
kernel/rootfs partitions with NVMEM cells provided by "firmware-info"
partition.

DeviceTree properties:

- nvmem-cells         : specify NVMEM cells
- nvmem-cell-names    : specify names of NVMEM cells
- fortinet,image-index: specify an image index of this partition (0/1)

NVMEM cells:

- "magic"        : magic number of firmware information area ("FSOC")
- "active-image" : image index for booting (0/1)
- "kernel-offset": kernel offset in block count (blocksize: 0x200)
- "kernel-length": kernel length in block count (blocksize: 0x200)

DeviceTree example:

partitions {
	compatible = "fixed-partitions"+
	#address-cells = <1>;
	#size-cells = <1>;

	partition@1c0000 {
		reg = <0x1c0000 0x10000>;
		label = "firmware-info";

		nvmem-layout {
			compatible = "fixed-layout";
			#address-cells = <1>;
			#size-cells = <1>;

			fwinfo_magic: magic@160 {
				reg = <0x160 0x4>;
			};

			fwinfo_active_image: active-image@170 {
				reg = <0x170 0x1>;
			};

			fwinfo_kernel1_offset: kernel-offset@180 {
				reg = <0x180 0x4>;
			};

			fwinfo_kernel1_size: kernel-size@184 {
				reg = <0x184 0x4>;
			};

			fwinfo_kernel2_offset: kernel-offset@190 {
				reg = <0x190 0x4>;
			};

			fwinfo_kernel2_size: kernel-size@194 {
				reg = <0x194 0x4>;
			};
		};
	};

	partition@200000 {
		compatible = "fortinet,fortigate-firmware";
		reg = <0x200000 0x1e00000>;
		label = "firmware";
		nvmem-cells = <&fwinfo_magic>,
			      <&fwinfo_active_image>,
			      <&fwinfo_kernel1_offset>,
			      <&fwinfo_kernel1_size>;
		nvmem-cell-names = "magic",
				   "active-image",
				   "kernel-offset",
				   "kernel-length";
		fortinet,image-index = <0>;
	};

	partition@2000000 {
		compatible = "fortinet,fortigate-firmware";
		reg = <0x2000000 0x1e00000>;
		label = "firmware2";
		nvmem-cells = <&fwinfo_magic>,
			      <&fwinfo_active_image>,
			      <&fwinfo_kernel2_offset>,
			      <&fwinfo_kernel2_size>;
		nvmem-cell-names = "magic",
				   "active-image",
				   "kernel-offset",
				   "kernel-length";
		fortinet,image-index = <1>;
	};
};

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
Enable fortigate-fw mtdsplit driver on mvebu/cortexa9 subtarget to
handle dual-boot on Fortinet FortiGate/FortiWiFi devices.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
Add fwinfo NVMEM and firmware partition nodes to the common dtsi for
Fortinet FortiGate/FortiWiFi 30E/5xE devices, to provide required
information for fortigate-fw mtdsplit driver.
firmware* partitions replace each kernel/rootfs partition nodes.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
Set DEVICE_COMPAT_MESSAGE with "mtdsplit" in the common definition for
Fortinet FortiGate/FortiWiFi 30E/5xE devices.
This makes generated images detectable as newer images that has
"firmware"/"firmware2" partitions instead of each kernel/rootfs
partitions by sysupgrade script for Fortinet FortiGate/FortiWiFi devices
(fortinet.sh).

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
Update the sysupgrade script for Fortinet devices (fortinet.sh) to
handle dual-boot for that devices.
The new script able to handle downgrading with the firmware images older
than dual-boot support for Fortinet FortiGate/FortiWiFi devices.

BTW, rootfs offset/length values not required for booting OpenWrt are
not handled on the new script.

Additionally, add functions to check compatibility of the specified
image and the current device.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
@github-actions github-actions bot added kernel pull request/issue with Linux kernel related changes target/mvebu pull request/issue for mvebu target labels Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel pull request/issue with Linux kernel related changes target/mvebu pull request/issue for mvebu target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant