mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 02:17:58 +00:00 
			
		
		
		
	mediatek: add sonicfi rap630w 211g
Signed-off-by: CybertanYingWei <Yingwei.Huang@cybertan.com.tw>
This commit is contained in:
		 CybertanYingWei
					CybertanYingWei
				
			
				
					committed by
					
						 John Crispin
						John Crispin
					
				
			
			
				
	
			
			
			 John Crispin
						John Crispin
					
				
			
						parent
						
							16ebaf4fa3
						
					
				
				
					commit
					06b8b32623
				
			
							
								
								
									
										2
									
								
								.github/workflows/build-dev.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/build-dev.yml
									
									
									
									
										vendored
									
									
								
							| @@ -21,7 +21,7 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         target: [ 'cig_wf186h', 'cig_wf186w', 'cig_wf188n', 'cig_wf196', 'cig_wf189', 'cybertan_eww631-a1', 'cybertan_eww631-b1','sonicfi_rap630c-311g', 'sonicfi_rap630w-311g', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_eap104', 'edgecore_eap105', 'edgecore_eap111', 'edgecore_eap112', 'edgecore_oap101', 'edgecore_oap101-6e', 'edgecore_oap101e', 'edgecore_oap101e-6e', 'hfcl_ion4xe', 'hfcl_ion4xi', 'hfcl_ion4x', 'hfcl_ion4x_2', 'hfcl_ion4x_3', 'hfcl_ion4xi_w', 'hfcl_ion4x_w', 'indio_um-305ax', 'sercomm_ap72tip', 'udaya_a6-id2', 'wallys_dr5018', 'wallys_dr6018', 'wallys_dr6018-v4', 'yuncore_ax820', 'yuncore_ax840', 'yuncore_fap640', 'yuncore_fap650', 'yuncore_fap655' ] |         target: [ 'cig_wf186h', 'cig_wf186w', 'cig_wf188n', 'cig_wf196', 'cig_wf189', 'cybertan_eww631-a1', 'cybertan_eww631-b1','sonicfi_rap630c-311g', 'sonicfi_rap630w-311g', 'sonicfi_rap630w-211g', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_eap104', 'edgecore_eap105', 'edgecore_eap111', 'edgecore_eap112', 'edgecore_oap101', 'edgecore_oap101-6e', 'edgecore_oap101e', 'edgecore_oap101e-6e', 'hfcl_ion4xe', 'hfcl_ion4xi', 'hfcl_ion4x', 'hfcl_ion4x_2', 'hfcl_ion4x_3', 'hfcl_ion4xi_w', 'hfcl_ion4x_w', 'indio_um-305ax', 'sercomm_ap72tip', 'udaya_a6-id2', 'wallys_dr5018', 'wallys_dr6018', 'wallys_dr6018-v4', 'yuncore_ax820', 'yuncore_ax840', 'yuncore_fap640', 'yuncore_fap650', 'yuncore_fap655' ] | ||||||
|  |  | ||||||
|     steps: |     steps: | ||||||
|     - uses: actions/checkout@v3 |     - uses: actions/checkout@v3 | ||||||
|   | |||||||
| @@ -1,5 +1,26 @@ | |||||||
| #!/bin/sh | #!/bin/sh | ||||||
|  |  | ||||||
|  | . /lib/functions.sh | ||||||
|  | . /lib/functions/system.sh | ||||||
|  |  | ||||||
|  | mt76_generate_macs() { | ||||||
|  | 	sysfs="/sys/class/ieee80211" | ||||||
|  | 	board=$(board_name) | ||||||
|  |  | ||||||
|  | 	case ${board} in | ||||||
|  | 	sonicfi,rap630w-211g) | ||||||
|  | 		eth=$(fw_printenv | grep ethaddr | cut -d= -f2) | ||||||
|  | 		mac1=$(macaddr_add ${eth} 2) | ||||||
|  | 		mac2=$(macaddr_add ${eth} 3) | ||||||
|  | 		[ -d ${sysfs}/phy0 ] && echo ${mac1} > ${sysfs}/phy0/macaddress | ||||||
|  | 		[ -d ${sysfs}/phy1 ] && echo ${mac2} > ${sysfs}/phy1/macaddress | ||||||
|  | 		;; | ||||||
|  | 	*) | ||||||
|  | 		;; | ||||||
|  | 	esac | ||||||
|  | } | ||||||
|  |  | ||||||
| [ "${ACTION}" = "add" ] && { | [ "${ACTION}" = "add" ] && { | ||||||
|  | 	mt76_generate_macs | ||||||
| 	/sbin/wifi config | 	/sbin/wifi config | ||||||
| } | } | ||||||
|   | |||||||
| @@ -0,0 +1,560 @@ | |||||||
|  | // SPDX-License-Identifier: GPL-2.0-or-later OR MIT | ||||||
|  |  | ||||||
|  | /dts-v1/; | ||||||
|  | #include <dt-bindings/input/input.h> | ||||||
|  | #include <dt-bindings/gpio/gpio.h> | ||||||
|  |  | ||||||
|  | #include "mt7981.dtsi" | ||||||
|  |  | ||||||
|  | / { | ||||||
|  | 	aliases { | ||||||
|  | 		serial0 = &uart0; | ||||||
|  | 	}; | ||||||
|  |  | ||||||
|  | 	chosen { | ||||||
|  | 		stdout-path = "serial0:115200n8"; | ||||||
|  | 	}; | ||||||
|  |  | ||||||
|  | 	memory { | ||||||
|  | 		reg = <0 0x40000000 0 0x10000000>; | ||||||
|  | 	}; | ||||||
|  |  | ||||||
|  | 	gpio-keys { | ||||||
|  | 		compatible = "gpio-keys"; | ||||||
|  |  | ||||||
|  | 		reset { | ||||||
|  | 			label = "reset"; | ||||||
|  | 			gpios = <&pio 1 GPIO_ACTIVE_LOW>; | ||||||
|  | 			linux,code = <KEY_RESTART>; | ||||||
|  | 		}; | ||||||
|  |  | ||||||
|  | 		mesh { | ||||||
|  | 			label = "mesh"; | ||||||
|  | 			gpios = <&pio 0 GPIO_ACTIVE_LOW>; | ||||||
|  | 			linux,code = <BTN_9>; | ||||||
|  | 			linux,input-type = <EV_SW>; | ||||||
|  | 		}; | ||||||
|  | 	}; | ||||||
|  |  | ||||||
|  | 	leds { | ||||||
|  | 		compatible = "gpio-leds"; | ||||||
|  |  | ||||||
|  | 		led_blue { | ||||||
|  | 			label = "sys:blue"; | ||||||
|  | 			gpios = <&pio 23 GPIO_ACTIVE_HIGH>; | ||||||
|  | 			linux,default-trigger = "timer"; | ||||||
|  | 			active-delay = <500>; | ||||||
|  | 			inactive-delay = <500>; | ||||||
|  | 			default-state="on"; | ||||||
|  | 		}; | ||||||
|  |  | ||||||
|  | 		led_green { | ||||||
|  | 			label = "sys:green"; | ||||||
|  | 			gpios = <&pio 24 GPIO_ACTIVE_HIGH>; | ||||||
|  | 			linux,default-trigger = "timer"; | ||||||
|  | 			active-delay = <500>; | ||||||
|  | 			inactive-delay = <500>; | ||||||
|  | 			default-state="on"; | ||||||
|  | 		}; | ||||||
|  |  | ||||||
|  | 		led_red { | ||||||
|  | 			label = "sys:red"; | ||||||
|  | 			gpios = <&pio 25 GPIO_ACTIVE_LOW>; | ||||||
|  | 			linux,default-trigger = "timer"; | ||||||
|  | 			active-delay = <500>; | ||||||
|  | 			inactive-delay = <500>; | ||||||
|  | 			default-state="on"; | ||||||
|  | 		}; | ||||||
|  | 	}; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | ð { | ||||||
|  |         status = "okay"; | ||||||
|  |  | ||||||
|  |         gmac0: mac@0 { | ||||||
|  |                 compatible = "mediatek,eth-mac"; | ||||||
|  |                 reg = <0>; | ||||||
|  |                 phy-mode = "2500base-x"; | ||||||
|  |  | ||||||
|  |                 fixed-link { | ||||||
|  |                         speed = <2500>; | ||||||
|  |                         full-duplex; | ||||||
|  |                         pause; | ||||||
|  |                 }; | ||||||
|  |         }; | ||||||
|  |  | ||||||
|  | 		gmac1: mac@1 { | ||||||
|  | 			compatible = "mediatek,eth-mac"; | ||||||
|  | 			reg = <1>; | ||||||
|  | 			phy-mode = "gmii"; | ||||||
|  | 			phy-handle = <&phy0>; | ||||||
|  | 		}; | ||||||
|  |  | ||||||
|  |         mdio: mdio-bus { | ||||||
|  |                 #address-cells = <1>; | ||||||
|  |                 #size-cells = <0>; | ||||||
|  |  | ||||||
|  | 		phy0: ethernet-phy@0 { | ||||||
|  | 			compatible = "ethernet-phy-id03a2.9461"; | ||||||
|  | 			reg = <0>; | ||||||
|  | 			phy-mode = "gmii"; | ||||||
|  | 			nvmem-cells = <&phy_calibration>; | ||||||
|  | 			nvmem-cell-names = "phy-cal-data"; | ||||||
|  | 		}; | ||||||
|  |  | ||||||
|  | 		switch@0 { | ||||||
|  | 					compatible = "mediatek,mt7531"; | ||||||
|  | 					reg = <31>; | ||||||
|  | 					reset-gpios = <&pio 39 0>; | ||||||
|  |  | ||||||
|  | 					ports { | ||||||
|  | 							#address-cells = <1>; | ||||||
|  | 							#size-cells = <0>; | ||||||
|  |  | ||||||
|  | 							port@0 { | ||||||
|  | 									reg = <0>; | ||||||
|  | 									label = "lan1"; | ||||||
|  | 							}; | ||||||
|  |  | ||||||
|  | 							port@1 { | ||||||
|  | 									reg = <1>; | ||||||
|  | 									label = "lan2"; | ||||||
|  | 							}; | ||||||
|  |  | ||||||
|  | 							port@2 { | ||||||
|  | 									reg = <2>; | ||||||
|  | 									label = "lan3"; | ||||||
|  | 							}; | ||||||
|  |  | ||||||
|  | 							port@6 { | ||||||
|  | 									reg = <6>; | ||||||
|  | 									label = "cpu"; | ||||||
|  | 									ethernet = <&gmac0>; | ||||||
|  | 									phy-mode = "2500base-x"; | ||||||
|  |  | ||||||
|  | 									fixed-link { | ||||||
|  | 											speed = <2500>; | ||||||
|  | 											full-duplex; | ||||||
|  | 											pause; | ||||||
|  | 									}; | ||||||
|  | 							}; | ||||||
|  | 					}; | ||||||
|  |                 }; | ||||||
|  |         }; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | &spi0 { | ||||||
|  | 	pinctrl-names = "default"; | ||||||
|  | 	pinctrl-0 = <&spi0_flash_pins>; | ||||||
|  | 	status = "okay"; | ||||||
|  |  | ||||||
|  | 	spi_nand: flash@0 { | ||||||
|  | 		#address-cells = <1>; | ||||||
|  | 		#size-cells = <1>; | ||||||
|  | 		compatible = "spi-nand"; | ||||||
|  | 		reg = <0>; | ||||||
|  |  | ||||||
|  | 		spi-max-frequency = <52000000>; | ||||||
|  | 		spi-tx-buswidth = <4>; | ||||||
|  | 		spi-rx-buswidth = <4>; | ||||||
|  |  | ||||||
|  | 		partitions: partitions { | ||||||
|  | 			compatible = "fixed-partitions"; | ||||||
|  | 			#address-cells = <1>; | ||||||
|  | 			#size-cells = <1>; | ||||||
|  |  | ||||||
|  | 			partition@0 { | ||||||
|  | 				label = "BL2"; | ||||||
|  | 				reg = <0x00 0x100000>; | ||||||
|  | 				read-only; | ||||||
|  | 			}; | ||||||
|  |  | ||||||
|  | 			partition@100000 { | ||||||
|  | 				label = "u-boot-env"; | ||||||
|  | 				reg = <0x0100000 0x0080000>; | ||||||
|  | 			}; | ||||||
|  |  | ||||||
|  | 			factory: partition@180000 { | ||||||
|  | 				label = "Factory"; | ||||||
|  | 				reg = <0x180000 0x200000>; | ||||||
|  | 				read-only; | ||||||
|  |  | ||||||
|  | 				compatible = "nvmem-cells"; | ||||||
|  | 				#address-cells = <1>; | ||||||
|  | 				#size-cells = <1>; | ||||||
|  |  | ||||||
|  | 				macaddr_factory_4: macaddr@4 { | ||||||
|  | 					reg = <0x4 0x6>; | ||||||
|  | 				}; | ||||||
|  | 			}; | ||||||
|  |  | ||||||
|  | 			partition@380000 { | ||||||
|  | 				label = "FIP"; | ||||||
|  | 				reg = <0x380000 0x200000>; | ||||||
|  | 				read-only; | ||||||
|  | 			}; | ||||||
|  |  | ||||||
|  | 			partition@580000 { | ||||||
|  | 				label = "ubi"; | ||||||
|  | 				reg = <0x580000 0x6000000>; | ||||||
|  | 			}; | ||||||
|  |  | ||||||
|  | 			partition@7580000 { | ||||||
|  | 				label = "devinfo"; | ||||||
|  | 				reg = <0x6580000 0x00080000>; | ||||||
|  | 			}; | ||||||
|  |  | ||||||
|  | 			partition@7600000 { | ||||||
|  | 				label ="certificates"; | ||||||
|  | 				reg = <0x6600000 0x00080000>; | ||||||
|  | 			}; | ||||||
|  | 		}; | ||||||
|  | 	}; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | &pio { | ||||||
|  | 	i2c_pins: i2c-pins-g0 { | ||||||
|  | 		mux { | ||||||
|  | 			function = "i2c"; | ||||||
|  | 			groups = "i2c0_1"; | ||||||
|  | 		}; | ||||||
|  | 	}; | ||||||
|  | 	spi0_flash_pins: spi0-pins { | ||||||
|  | 		mux { | ||||||
|  | 			function = "spi"; | ||||||
|  | 			groups = "spi0", "spi0_wp_hold"; | ||||||
|  | 		}; | ||||||
|  |  | ||||||
|  | 		conf-pu { | ||||||
|  | 			pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP"; | ||||||
|  | 			drive-strength = <MTK_DRIVE_8mA>; | ||||||
|  | 			bias-pull-up = <MTK_PUPD_SET_R1R0_11>; | ||||||
|  | 		}; | ||||||
|  |  | ||||||
|  | 		conf-pd { | ||||||
|  | 			pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO"; | ||||||
|  | 			drive-strength = <MTK_DRIVE_8mA>; | ||||||
|  | 			bias-pull-down = <MTK_PUPD_SET_R1R0_11>; | ||||||
|  | 		}; | ||||||
|  | 	}; | ||||||
|  | 	pse_out_en { | ||||||
|  | 			gpios = <&pio 27 GPIO_ACTIVE_HIGH>; | ||||||
|  | 			output-high; | ||||||
|  | 	}; | ||||||
|  | 	pse_int_n { | ||||||
|  | 			gpios = <&pio 29 GPIO_ACTIVE_LOW>; | ||||||
|  | 			input; | ||||||
|  | 	};	 | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | &hnat { | ||||||
|  |         mtketh-wan = "eth1"; | ||||||
|  |         mtketh-lan = "lan"; | ||||||
|  |         mtketh-max-gmac = <2>; | ||||||
|  |         status = "okay"; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | &i2c0 { | ||||||
|  | 	pinctrl-names = "default"; | ||||||
|  | 	pinctrl-0 = <&i2c_pins>; | ||||||
|  | 	status = "okay"; | ||||||
|  |  | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | &pio { | ||||||
|  | 	wf_dbdc_pins: wf_dbdc-pins { | ||||||
|  | 		mux { | ||||||
|  | 			function = "eth"; | ||||||
|  | 			groups = "wf0_mode1"; | ||||||
|  | 		}; | ||||||
|  | 		conf { | ||||||
|  | 			pins = "WF_HB1", "WF_HB2", "WF_HB3", "WF_HB4", | ||||||
|  | 			       "WF_HB0", "WF_HB0_B", "WF_HB5", "WF_HB6", | ||||||
|  | 			       "WF_HB7", "WF_HB8", "WF_HB9", "WF_HB10", | ||||||
|  | 			       "WF_TOP_CLK", "WF_TOP_DATA", "WF_XO_REQ", | ||||||
|  | 			       "WF_CBA_RESETB", "WF_DIG_RESETB"; | ||||||
|  | 			drive-strength = <MTK_DRIVE_4mA>; | ||||||
|  | 		}; | ||||||
|  | 	}; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | &wbsys { | ||||||
|  | 	status = "okay"; | ||||||
|  |  | ||||||
|  | 	mediatek,mtd-eeprom = <&factory 0x0>; | ||||||
|  | 	pinctrl-names = "dbdc"; | ||||||
|  | 	pinctrl-0 = <&wf_dbdc_pins>; | ||||||
|  | 	power-limits { | ||||||
|  | 		r0 { | ||||||
|  | 			regdomain = "fcc"; | ||||||
|  | 			txpower-2g { | ||||||
|  | 				r0 { | ||||||
|  | 					channels = <1 1>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-cck = <38 38 38 38>; | ||||||
|  | 					rates-ofdm = <37 37 37 37 37 37 37 37>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<1 36 36 36 36 36 36 36 36 34 33>, | ||||||
|  | 					<3 34 34 34 34 34 34 34 34 34 33>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<4 36 36 36 36 36 36 36 36 34 33 32 32>, | ||||||
|  | 					<3 34 34 34 34 34 34 34 34 34 33 32 32>; | ||||||
|  | 				}; | ||||||
|  | 				r1 { | ||||||
|  | 					channels = <2 3>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-cck = <38 38 38 38>; | ||||||
|  | 					rates-ofdm = <38 38 38 38 38 38 38 37>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<1 38 38 38 38 38 38 37 36 34 33>, | ||||||
|  | 					<3 34 34 34 34 34 34 34 34 34 33>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<4 38 38 38 38 38 38 37 36 34 33 32 32>, | ||||||
|  | 					<3 34 34 34 34 34 34 34 34 34 33 32 32>; | ||||||
|  | 				}; | ||||||
|  | 				r2 { | ||||||
|  | 					channels = <4 8>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-cck = <38 38 38 38>; | ||||||
|  | 					rates-ofdm = <38 38 38 38 38 38 38 37>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<1 38 38 38 38 38 38 37 36 34 33>, | ||||||
|  | 					<3 36 36 36 36 36 36 36 36 34 33>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<4 38 38 38 38 38 38 37 36 34 33 32 32>, | ||||||
|  | 					<3 36 36 36 36 36 36 36 36 34 33 32 32>; | ||||||
|  | 				}; | ||||||
|  | 				r3 { | ||||||
|  | 					channels = <9 14>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-cck = <38 38 38 38>; | ||||||
|  | 					rates-ofdm = <38 38 38 38 38 38 38 37>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<1 38 38 38 38 38 38 37 36 34 33>, | ||||||
|  | 					<3 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<4 38 38 38 38 38 38 37 36 34 33 32 32>, | ||||||
|  | 					<3 32 32 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 				}; | ||||||
|  | 			}; | ||||||
|  | 			txpower-5g { | ||||||
|  | 				r0 { | ||||||
|  | 					channels = <184 196>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <40 40 40 40 40 40 39 38>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<2 40 40 40 40 40 39 38 36 35 34>, | ||||||
|  | 					<2 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<5 40 40 40 40 40 39 38 36 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r1 { | ||||||
|  | 					channels = <8 16>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <40 40 40 40 40 40 39 38>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<2 40 40 40 40 40 39 38 36 35 34>, | ||||||
|  | 					<2 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<5 40 40 40 40 40 39 38 36 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r2 { | ||||||
|  | 					channels = <36 40>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <40 40 40 40 40 40 39 38>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<1 40 40 40 40 40 39 38 36 35 34>, | ||||||
|  | 					<1 38 38 38 38 38 38 38 36 35 34>, | ||||||
|  | 					<2 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<4 40 40 40 40 40 39 38 36 35 34 32 32>, | ||||||
|  | 					<1 38 38 38 38 38 38 38 36 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r3 { | ||||||
|  | 					channels = <44 44>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <40 40 40 40 40 40 39 38>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<2 40 40 40 40 40 39 38 36 35 34>, | ||||||
|  | 					<2 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<5 40 40 40 40 40 39 38 36 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r4 { | ||||||
|  | 					channels = <48 48>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <39 39 39 39 39 39 39 38>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<2 40 40 40 40 40 39 38 36 35 34>, | ||||||
|  | 					<2 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<5 40 40 40 40 40 39 38 36 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r5 { | ||||||
|  | 					channels = <52 96>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <36 36 36 36 36 36 36 36>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<3 36 36 36 36 36 36 36 36 35 34>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<6 36 36 36 36 36 36 36 36 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r6 { | ||||||
|  | 					channels = <100 112>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <36 36 36 36 36 36 36 36>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<2 36 36 36 36 36 36 36 36 35 34>, | ||||||
|  | 					<1 35 35 35 35 35 35 35 35 35 34>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<5 36 36 36 36 36 36 36 36 35 34 32 32>, | ||||||
|  | 					<1 35 35 35 35 35 35 35 35 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r7 { | ||||||
|  | 					channels = <116 144>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <36 36 36 36 36 36 36 36>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<3 36 36 36 36 36 36 36 36 35 34>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<6 36 36 36 36 36 36 36 36 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r8 { | ||||||
|  | 					channels = <149 181>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <40 40 40 40 40 40 39 38>; | ||||||
|  | 					rates-mcs = | ||||||
|  | 					<3 40 40 40 40 40 39 38 36 35 34>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru = | ||||||
|  | 					<6 40 40 40 40 40 39 38 36 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 			}; | ||||||
|  | 		}; | ||||||
|  | 		r1 { | ||||||
|  | 			regdomain = "etsi"; | ||||||
|  | 			txpower-2g { | ||||||
|  | 				r0 { | ||||||
|  | 					channels = <1 14>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-cck = <29 29 29 29>; | ||||||
|  | 					rates-ofdm = <30 30 30 30 30 30 30 30>; | ||||||
|  | 					rates-mcs =  | ||||||
|  | 					<4 28 28 28 28 28 28 28 28 28 28>; | ||||||
|  | 					rates-ru =  | ||||||
|  | 					<7 28 28 28 28 28 28 28 28 28 28 28 28>; | ||||||
|  | 				}; | ||||||
|  | 			}; | ||||||
|  | 			txpower-5g { | ||||||
|  | 				r0 { | ||||||
|  | 					channels = <184 196>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <33 33 33 33 33 33 33 33>; | ||||||
|  | 					rates-mcs =  | ||||||
|  | 					<4 33 33 33 33 33 33 33 33 33 33>; | ||||||
|  | 					rates-ru =  | ||||||
|  | 					<6 33 33 33 33 33 33 33 33 33 33 32 32>, | ||||||
|  | 					<1 33 33 33 33 33 33 33 33 33 33 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r1 { | ||||||
|  | 					channels = <8 16>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <33 33 33 33 33 33 33 33>; | ||||||
|  | 					rates-mcs =  | ||||||
|  | 					<4 33 33 33 33 33 33 33 33 33 33>; | ||||||
|  | 					rates-ru =  | ||||||
|  | 					<6 33 33 33 33 33 33 33 33 33 33 32 32>, | ||||||
|  | 					<1 33 33 33 33 33 33 33 33 33 33 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r2 { | ||||||
|  | 					channels = <36 48>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <33 33 33 33 33 33 33 33>; | ||||||
|  | 					rates-mcs =  | ||||||
|  | 					<4 33 33 33 33 33 33 33 33 33 33>; | ||||||
|  | 					rates-ru =  | ||||||
|  | 					<6 33 33 33 33 33 33 33 33 33 33 32 32>, | ||||||
|  | 					<1 33 33 33 33 33 33 33 33 33 33 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r3 { | ||||||
|  | 					channels = <52 96>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <33 33 33 33 33 33 33 33>; | ||||||
|  | 					rates-mcs =  | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32>, | ||||||
|  | 					<3 33 33 33 33 33 33 33 33 33 33>; | ||||||
|  | 					rates-ru =  | ||||||
|  | 					<4 32 32 32 32 32 32 32 32 32 32 32 32>, | ||||||
|  | 					<2 33 33 33 33 33 33 33 33 33 33 32 32>, | ||||||
|  | 					<1 33 33 33 33 33 33 33 33 33 33 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r4 { | ||||||
|  | 					channels = <100 128>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <40 40 40 40 40 40 39 38>; | ||||||
|  | 					rates-mcs =  | ||||||
|  | 					<3 40 40 40 40 40 39 38 36 35 34>, | ||||||
|  | 					<1 40 40 40 39 39 38 36 35 34 33>; | ||||||
|  | 					rates-ru =  | ||||||
|  | 					<6 40 40 40 40 40 39 38 36 35 34 32 32>, | ||||||
|  | 					<1 40 40 40 39 39 38 36 35 34 33 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r5 { | ||||||
|  | 					channels = <132 144>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <40 40 40 40 40 40 39 38>; | ||||||
|  | 					rates-mcs =  | ||||||
|  | 					<3 40 40 40 40 40 39 38 36 35 34>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru =  | ||||||
|  | 					<6 40 40 40 40 40 39 38 36 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 				r6 { | ||||||
|  | 					channels = <149 181>; | ||||||
|  | 					txs-delta = <0 0 0>; | ||||||
|  | 					rates-ofdm = <40 40 40 40 40 40 39 38>; | ||||||
|  | 					rates-mcs =  | ||||||
|  | 					<3 40 40 40 40 40 39 38 36 35 34>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32>; | ||||||
|  | 					rates-ru =  | ||||||
|  | 					<6 40 40 40 40 40 39 38 36 35 34 32 32>, | ||||||
|  | 					<1 32 32 32 32 32 32 32 32 32 32 30 30>; | ||||||
|  | 				}; | ||||||
|  | 			}; | ||||||
|  | 		}; | ||||||
|  | 	}; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | &uart0 { | ||||||
|  | 	status = "okay"; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | &watchdog { | ||||||
|  | 	status = "okay"; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | / { | ||||||
|  | 	model = "SONICFI RAP630W-211G"; | ||||||
|  | 	compatible = "sonicfi,rap630w-211g", "mediatek,mt7981"; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -79,6 +79,34 @@ define Device/edgecore_eap112 | |||||||
| endef | endef | ||||||
| TARGET_DEVICES += edgecore_eap112 | TARGET_DEVICES += edgecore_eap112 | ||||||
|  |  | ||||||
|  | define Device/sonicfi_rap630w_211g | ||||||
|  |   DEVICE_VENDOR := SONICFI | ||||||
|  |   DEVICE_MODEL := RAP630W-211G | ||||||
|  |   DEVICE_DTS := mt7981b-sonicfi-rap630w-211g | ||||||
|  |   DEVICE_DTS_DIR := $(DTS_DIR)/mediatek | ||||||
|  |   SUPPORTED_DEVICES := sonicfi,rap630w-211g | ||||||
|  |   DEVICE_PACKAGES := kmod-mt7981-firmware kmod-mt7915e kmod-hwmon-tps23861 \ | ||||||
|  | 	e2fsprogs f2fsck mkf2fs | ||||||
|  |   KERNEL := kernel-bin | lzma | \ | ||||||
|  | 	  fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | ||||||
|  |   KERNEL_INITRAMFS := kernel-bin | lzma | \ | ||||||
|  | 	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k | ||||||
|  |   KERNEL_INITRAMFS_SUFFIX := -recovery.itb | ||||||
|  |   KERNEL_IN_UBI := 1 | ||||||
|  |   UBINIZE_OPTS := -E 5 | ||||||
|  |   BLOCKSIZE := 128k | ||||||
|  |   PAGESIZE := 2048 | ||||||
|  |   IMAGE_SIZE := 65536k | ||||||
|  |   ROOTFSNAME_IN_UBI := rootfs | ||||||
|  |   UBOOTENV_IN_UBI := 1 | ||||||
|  |   IMAGES := sysupgrade.tar | ||||||
|  |   IMAGE/sysupgrade.itb := append-kernel | \ | ||||||
|  | 	 fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | \ | ||||||
|  | 	 pad-rootfs | append-metadata | ||||||
|  |   IMAGE/sysupgrade.tar := sysupgrade-tar | append-metadata | ||||||
|  | endef | ||||||
|  | TARGET_DEVICES += sonicfi_rap630w_211g | ||||||
|  |  | ||||||
| define Device/mt7981-spim-nand-gsw | define Device/mt7981-spim-nand-gsw | ||||||
|   DEVICE_VENDOR := MediaTek |   DEVICE_VENDOR := MediaTek | ||||||
|   DEVICE_MODEL := mt7981-spim-nand-gsw |   DEVICE_MODEL := mt7981-spim-nand-gsw | ||||||
|   | |||||||
							
								
								
									
										46
									
								
								feeds/mediatek-sdk/mediatek/mt7981/base-files/etc/board.d/02_network
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										46
									
								
								feeds/mediatek-sdk/mediatek/mt7981/base-files/etc/board.d/02_network
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| @@ -1,8 +1,9 @@ | |||||||
| #!/bin/sh | #!/bin/sh | ||||||
|  | . /lib/uboot-envtools.sh | ||||||
| . /lib/functions.sh | . /lib/functions.sh | ||||||
| . /lib/functions/uci-defaults.sh | . /lib/functions/uci-defaults.sh | ||||||
| . /lib/functions/system.sh | . /lib/functions/system.sh | ||||||
|  | . /lib/rap211g-envtools.sh | ||||||
|  |  | ||||||
| mediatek_setup_interfaces() | mediatek_setup_interfaces() | ||||||
| { | { | ||||||
| @@ -22,7 +23,10 @@ mediatek_setup_interfaces() | |||||||
| 	*2500wan-p5*) | 	*2500wan-p5*) | ||||||
| 		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" wan | 		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" wan | ||||||
| 		;; | 		;; | ||||||
| 	*) | 	sonicfi,rap630w-211g) | ||||||
|  | 		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" eth1 | ||||||
|  | 		;;		 | ||||||
|  | 	*)	 | ||||||
| 		ucidef_set_interfaces_lan_wan "eth0" "eth1" | 		ucidef_set_interfaces_lan_wan "eth0" "eth1" | ||||||
| 		;; | 		;; | ||||||
| 	esac | 	esac | ||||||
| @@ -43,6 +47,44 @@ mediatek_setup_macs() | |||||||
| 		lan_mac_offset="0x24" | 		lan_mac_offset="0x24" | ||||||
| 		wan_mac_offset="0x2a" | 		wan_mac_offset="0x2a" | ||||||
| 		;; | 		;; | ||||||
|  | 	sonicfi,rap630w-211g) | ||||||
|  | 		sysfs="/sys/class/ieee80211" | ||||||
|  | 		env_dev=$(get_boot_param "boot_param.env_part") | ||||||
|  | 		if [ -n "$env_dev" ]; then | ||||||
|  | 			mtdnum="$( find_mtd_index "$CI_UBIPART" )" | ||||||
|  | 			if [ ! "$mtdnum" ]; then | ||||||
|  | 				echo "cannot find ubi mtd partition $CI_UBIPART" | ||||||
|  | 				return 1 | ||||||
|  | 			fi | ||||||
|  |  | ||||||
|  | 			ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 			if [ ! "$ubidev" ]; then | ||||||
|  | 				ubiattach -m "$mtdnum" | ||||||
|  | 				sync | ||||||
|  | 				ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 			fi | ||||||
|  |  | ||||||
|  | 			env_ubivol="$( nand_find_volume "${ubidev}" ${env_dev} )" | ||||||
|  | 			if [ -n "${env_ubivol}" ]; then | ||||||
|  | 				#ubootenv_add_uci_config "/dev/$env_ubivol" "0" "0x80000" "0x80000" 1 | ||||||
|  | 				echo "/dev/$env_ubivol 0 0x80000 0x80000 1" > /etc/fw_env.config | ||||||
|  | 			fi | ||||||
|  | 		fi | ||||||
|  | 		#echo "/dev/ubi0_0 0 0x80000 0x80000 1" > /etc/fw_env.config | ||||||
|  | 		mac=$(fw_printenv | grep ethaddr | cut -d= -f2) | ||||||
|  | 		wan_mac=$(macaddr_canonicalize $mac) | ||||||
|  | 		[ -z "$mac" ] && return; | ||||||
|  | 		wan_mac=$(macaddr_canonicalize $mac) | ||||||
|  | 		lan_mac=$(macaddr_add "$wan_mac" 1) | ||||||
|  | 		ucidef_set_interface_macaddr "lan" "$lan_mac" | ||||||
|  | 		ucidef_set_interface_macaddr "wan" "$wan_mac" | ||||||
|  | 		ucidef_set_label_macaddr "$wan_mac" | ||||||
|  | 		mac1=$(macaddr_add ${mac} 2) | ||||||
|  | 		mac2=$(macaddr_add ${mac} 3) | ||||||
|  | 		[ -d ${sysfs}/phy0 ] && echo ${mac1} > ${sysfs}/phy0/macaddress | ||||||
|  | 		[ -d ${sysfs}/phy1 ] && echo ${mac2} > ${sysfs}/phy1/macaddress | ||||||
|  | 		return | ||||||
|  | 		;; | ||||||
| 	*) | 	*) | ||||||
| 		lan_mac_offset="0x2A" | 		lan_mac_offset="0x2A" | ||||||
| 		wan_mac_offset="0x24" | 		wan_mac_offset="0x24" | ||||||
|   | |||||||
| @@ -8,6 +8,9 @@ touch /etc/config/ubootenv | |||||||
|  |  | ||||||
| . /lib/uboot-envtools.sh | . /lib/uboot-envtools.sh | ||||||
| . /lib/functions.sh | . /lib/functions.sh | ||||||
|  | . /lib/functions/uci-defaults.sh | ||||||
|  | . /lib/functions/system.sh | ||||||
|  | . /lib/rap211g-envtools.sh | ||||||
|  |  | ||||||
| board=$(board_name) | board=$(board_name) | ||||||
|  |  | ||||||
| @@ -16,9 +19,31 @@ edgecore,eap111|\ | |||||||
| edgecore,eap112) | edgecore,eap112) | ||||||
| 	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000" | 	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000" | ||||||
| 	;; | 	;; | ||||||
|  | sonicfi,rap630w-211g) | ||||||
|  | 	#env_dev=$(cat /sys/module/boot_param/parameters/env_part 2>/dev/null) | ||||||
|  | 	env_dev=$(get_boot_param "boot_param.env_part") | ||||||
|  | 	if [ -n "$env_dev" ]; then | ||||||
|  | 		mtdnum="$( find_mtd_index "$CI_UBIPART" )" | ||||||
|  | 		if [ ! "$mtdnum" ]; then | ||||||
|  | 			echo "cannot find ubi mtd partition $CI_UBIPART" | ||||||
|  | 			return 1 | ||||||
|  | 		fi | ||||||
|  |  | ||||||
|  | 		ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 		if [ ! "$ubidev" ]; then | ||||||
|  | 			ubiattach -m "$mtdnum" | ||||||
|  | 			sync | ||||||
|  | 			ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 		fi | ||||||
|  |  | ||||||
|  | 		env_ubivol="$( nand_find_volume "${ubidev}" ${env_dev} )" | ||||||
|  | 		if [ -n "${env_ubivol}" ]; then | ||||||
|  | 			ubootenv_add_uci_config "/dev/$env_ubivol" "0" "0x80000" "0x80000" 1 | ||||||
|  | 		fi | ||||||
|  | 	fi | ||||||
|  | 	;;	 | ||||||
| esac | esac | ||||||
|  |  | ||||||
| config_load ubootenv | config_load ubootenv | ||||||
| config_foreach ubootenv_add_app_config | config_foreach ubootenv_add_app_config | ||||||
|  |  | ||||||
| exit 0 | exit 0 | ||||||
|   | |||||||
| @@ -0,0 +1,99 @@ | |||||||
|  | # | ||||||
|  | # Copyright (C) 2021 OpenWrt.org | ||||||
|  | # | ||||||
|  |  | ||||||
|  | . /lib/uboot-envtools.sh | ||||||
|  | . /lib/functions.sh | ||||||
|  | . /lib/functions/uci-defaults.sh | ||||||
|  | . /lib/functions/system.sh | ||||||
|  |  | ||||||
|  | CI_UBIPART=ubi | ||||||
|  |  | ||||||
|  | ubi_mknod() { | ||||||
|  |         local dir="$1" | ||||||
|  |         local dev="/dev/$(basename $dir)" | ||||||
|  |  | ||||||
|  |         [ -e "$dev" ] && return 0 | ||||||
|  |  | ||||||
|  |         local devid="$(cat $dir/dev)" | ||||||
|  |         local major="${devid%%:*}" | ||||||
|  |         local minor="${devid##*:}" | ||||||
|  |         mknod "$dev" c $major $minor | ||||||
|  | } | ||||||
|  |  | ||||||
|  | get_boot_param() | ||||||
|  | { | ||||||
|  | 	local cmdline_param=$(cat /proc/cmdline) | ||||||
|  | 	local name | ||||||
|  | 	for var in $cmdline_param | ||||||
|  | 	do | ||||||
|  | 		#echo "aaa---$var" | ||||||
|  | 		if [ $var == $1 ]; | ||||||
|  | 		then | ||||||
|  | 			echo "Y" | ||||||
|  | 			return | ||||||
|  | 		else | ||||||
|  | 			name=$(echo $var | awk -F '=' '{print $1}') | ||||||
|  | 			#echo "$name" | ||||||
|  | 			if [ $name == $1 ]; | ||||||
|  | 			then | ||||||
|  | 					echo $(echo $var | awk -F '=' '{print $2}') | ||||||
|  | 					return | ||||||
|  | 			fi | ||||||
|  | 		fi | ||||||
|  | 	done | ||||||
|  | 	echo "N" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | block_dev_path() { | ||||||
|  | 	local dev_path | ||||||
|  |  | ||||||
|  | 	case "$1" in | ||||||
|  | 	/dev/mmcblk*) | ||||||
|  | 		dev_path="$1" | ||||||
|  | 		;; | ||||||
|  | 	PARTLABEL=* | PARTUUID=*) | ||||||
|  | 		dev_path=$(blkid -t "$1" -o device) | ||||||
|  | 		[ -z "${dev_path}" -o $? -ne 0 ] && return 1 | ||||||
|  | 		;; | ||||||
|  | 	*) | ||||||
|  | 		return 1; | ||||||
|  | 		;; | ||||||
|  | 	esac | ||||||
|  |  | ||||||
|  | 	echo "${dev_path}" | ||||||
|  | 	return 0 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | nand_find_volume() { | ||||||
|  | 	local ubidevdir ubivoldir | ||||||
|  | 	ubidevdir="/sys/devices/virtual/ubi/$1" | ||||||
|  | 	[ ! -d "$ubidevdir" ] && return 1 | ||||||
|  | 	for ubivoldir in $ubidevdir/${1}_*; do | ||||||
|  | 		[ ! -d "$ubivoldir" ] && continue | ||||||
|  | 		if [ "$( cat $ubivoldir/name )" = "$2" ]; then | ||||||
|  | 			basename $ubivoldir | ||||||
|  | 			ubi_mknod "$ubivoldir" | ||||||
|  | 			return 0 | ||||||
|  | 		fi | ||||||
|  | 	done | ||||||
|  | } | ||||||
|  |  | ||||||
|  | nand_find_ubi() { | ||||||
|  | 	local ubidevdir ubidev mtdnum | ||||||
|  | 	mtdnum="$( find_mtd_index $1 )" | ||||||
|  | 	[ ! "$mtdnum" ] && return 1 | ||||||
|  | 	for ubidevdir in /sys/devices/virtual/ubi/ubi*; do | ||||||
|  | 		[ ! -d "$ubidevdir" ] && continue | ||||||
|  | 		cmtdnum="$( cat $ubidevdir/mtd_num )" | ||||||
|  | 		[ ! "$mtdnum" ] && continue | ||||||
|  | 		if [ "$mtdnum" = "$cmtdnum" ]; then | ||||||
|  | 			ubidev=$( basename $ubidevdir ) | ||||||
|  | 			ubi_mknod "$ubidevdir" | ||||||
|  | 			echo $ubidev | ||||||
|  | 			return 0 | ||||||
|  | 		fi | ||||||
|  | 	done | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -33,6 +33,10 @@ platform_do_upgrade() { | |||||||
| 		fi | 		fi | ||||||
| 		nand_do_upgrade "$1" | 		nand_do_upgrade "$1" | ||||||
| 		;; | 		;; | ||||||
|  | 	sonicfi,rap630w-211g) | ||||||
|  | 		chmod +x /tmp/root/lib/upgrade/sonicfi/nand_sonicfi_rap630w_211g.sh | ||||||
|  | 		/tmp/root/lib/upgrade/sonicfi/nand_sonicfi_rap630w_211g.sh "$1" | ||||||
|  | 		;;		 | ||||||
| 	esac | 	esac | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -48,6 +52,13 @@ platform_check_image() { | |||||||
| 		nand_do_platform_check "$board" "$1" | 		nand_do_platform_check "$board" "$1" | ||||||
| 		return $? | 		return $? | ||||||
| 		;; | 		;; | ||||||
|  | 	sonicfi,rap630w-211g) | ||||||
|  | 		[ "$magic" != "73797375" ] && { | ||||||
|  | 			echo "Invalid image type." | ||||||
|  | 			return 1 | ||||||
|  | 		} | ||||||
|  | 		return 0 | ||||||
|  | 		;;		 | ||||||
| 	esac | 	esac | ||||||
|  |  | ||||||
| 	return 0 | 	return 0 | ||||||
|   | |||||||
| @@ -0,0 +1,511 @@ | |||||||
|  | # Copyright (C) 2014 OpenWrt.org | ||||||
|  | # | ||||||
|  |  | ||||||
|  | . /lib/functions.sh | ||||||
|  |  | ||||||
|  | # 'kernel' partition on NAND contains the kernel | ||||||
|  | CI_KERNPART="${CI_KERNPART:-kernel}" | ||||||
|  |  | ||||||
|  | # 'ubi' partition on NAND contains UBI | ||||||
|  | CI_UBIPART="${CI_UBIPART:-ubi}" | ||||||
|  |  | ||||||
|  | # 'rootfs' partition on NAND contains the rootfs | ||||||
|  | CI_ROOTPART="${CI_ROOTPART:-rootfs}" | ||||||
|  |  | ||||||
|  | get_boot_param() | ||||||
|  | { | ||||||
|  | 	local cmdline_param=$(cat /proc/cmdline) | ||||||
|  | 	local name | ||||||
|  | 	for var in $cmdline_param | ||||||
|  | 	do | ||||||
|  | 		#echo "aaa---$var" | ||||||
|  | 		if [ $var == $1 ]; | ||||||
|  | 		then | ||||||
|  | 			echo "Y" | ||||||
|  | 			return | ||||||
|  | 		else | ||||||
|  | 			name=$(echo $var | awk -F '=' '{print $1}') | ||||||
|  | 			#echo "$name" | ||||||
|  | 			if [ $name == $1 ]; | ||||||
|  | 			then | ||||||
|  | 					echo $(echo $var | awk -F '=' '{print $2}') | ||||||
|  | 					return | ||||||
|  | 			fi | ||||||
|  | 		fi | ||||||
|  | 	done | ||||||
|  | 	echo "N" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | ubi_mknod() { | ||||||
|  | 	local dir="$1" | ||||||
|  | 	local dev="/dev/$(basename $dir)" | ||||||
|  |  | ||||||
|  | 	[ -e "$dev" ] && return 0 | ||||||
|  |  | ||||||
|  | 	local devid="$(cat $dir/dev)" | ||||||
|  | 	local major="${devid%%:*}" | ||||||
|  | 	local minor="${devid##*:}" | ||||||
|  | 	mknod "$dev" c $major $minor | ||||||
|  | } | ||||||
|  |  | ||||||
|  | nand_find_volume() { | ||||||
|  | 	local ubidevdir ubivoldir | ||||||
|  | 	ubidevdir="/sys/devices/virtual/ubi/$1" | ||||||
|  | 	[ ! -d "$ubidevdir" ] && return 1 | ||||||
|  | 	for ubivoldir in $ubidevdir/${1}_*; do | ||||||
|  | 		[ ! -d "$ubivoldir" ] && continue | ||||||
|  | 		if [ "$( cat $ubivoldir/name )" = "$2" ]; then | ||||||
|  | 			basename $ubivoldir | ||||||
|  | 			ubi_mknod "$ubivoldir" | ||||||
|  | 			return 0 | ||||||
|  | 		fi | ||||||
|  | 	done | ||||||
|  | } | ||||||
|  |  | ||||||
|  | nand_find_ubi() { | ||||||
|  | 	local ubidevdir ubidev mtdnum | ||||||
|  | 	mtdnum="$( find_mtd_index $1 )" | ||||||
|  | 	[ ! "$mtdnum" ] && return 1 | ||||||
|  | 	for ubidevdir in /sys/devices/virtual/ubi/ubi*; do | ||||||
|  | 		[ ! -d "$ubidevdir" ] && continue | ||||||
|  | 		cmtdnum="$( cat $ubidevdir/mtd_num )" | ||||||
|  | 		[ ! "$mtdnum" ] && continue | ||||||
|  | 		if [ "$mtdnum" = "$cmtdnum" ]; then | ||||||
|  | 			ubidev=$( basename $ubidevdir ) | ||||||
|  | 			ubi_mknod "$ubidevdir" | ||||||
|  | 			echo $ubidev | ||||||
|  | 			return 0 | ||||||
|  | 		fi | ||||||
|  | 	done | ||||||
|  | } | ||||||
|  |  | ||||||
|  | nand_get_magic_long() { | ||||||
|  | 	dd if="$1" skip=$2 bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' | ||||||
|  | } | ||||||
|  |  | ||||||
|  | get_magic_long_tar() { | ||||||
|  | 	( tar xf $1 $2 -O | dd bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2> /dev/null | ||||||
|  | } | ||||||
|  |  | ||||||
|  | identify_magic() { | ||||||
|  | 	local magic=$1 | ||||||
|  | 	case "$magic" in | ||||||
|  | 		"55424923") | ||||||
|  | 			echo "ubi" | ||||||
|  | 			;; | ||||||
|  | 		"31181006") | ||||||
|  | 			echo "ubifs" | ||||||
|  | 			;; | ||||||
|  | 		"68737173") | ||||||
|  | 			echo "squashfs" | ||||||
|  | 			;; | ||||||
|  | 		"d00dfeed") | ||||||
|  | 			echo "fit" | ||||||
|  | 			;; | ||||||
|  | 		"4349"*) | ||||||
|  | 			echo "combined" | ||||||
|  | 			;; | ||||||
|  | 		*) | ||||||
|  | 			echo "unknown $magic" | ||||||
|  | 			;; | ||||||
|  | 	esac | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | identify() { | ||||||
|  | 	identify_magic $(nand_get_magic_long "$1" "${2:-0}") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | identify_tar() { | ||||||
|  | 	identify_magic $(get_magic_long_tar "$1" "$2") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | nand_restore_config() { | ||||||
|  | 	sync | ||||||
|  | 	local ubidev=$( nand_find_ubi $CI_UBIPART ) | ||||||
|  | 	local ubivol="$( nand_find_volume $ubidev rootfs_data )" | ||||||
|  | 	[ ! "$ubivol" ] && | ||||||
|  | 		ubivol="$( nand_find_volume $ubidev $CI_ROOTPART )" | ||||||
|  | 	mkdir /tmp/new_root | ||||||
|  | 	if ! mount -t ubifs /dev/$ubivol /tmp/new_root; then | ||||||
|  | 		echo "mounting ubifs $ubivol failed" | ||||||
|  | 		rmdir /tmp/new_root | ||||||
|  | 		return 1 | ||||||
|  | 	fi | ||||||
|  | 	mv "$1" "/tmp/new_root/$BACKUP_FILE" | ||||||
|  | 	umount /tmp/new_root | ||||||
|  | 	sync | ||||||
|  | 	rmdir /tmp/new_root | ||||||
|  | } | ||||||
|  |  | ||||||
|  | nand_upgrade_prepare_ubi() { | ||||||
|  | 	local rootfs_length="$1" | ||||||
|  | 	local rootfs_type="$2" | ||||||
|  | 	local has_kernel="${3:-0}" | ||||||
|  | 	local has_env="${4:-0}" | ||||||
|  |  | ||||||
|  | 	local mtdnum="$( find_mtd_index "$CI_UBIPART" )" | ||||||
|  | 	if [ ! "$mtdnum" ]; then | ||||||
|  | 		echo "cannot find ubi mtd partition $CI_UBIPART" | ||||||
|  | 		return 1 | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	local ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 	if [ ! "$ubidev" ]; then | ||||||
|  | 		ubiattach -m "$mtdnum" | ||||||
|  | 		sync | ||||||
|  | 		ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	if [ ! "$ubidev" ]; then | ||||||
|  | 		ubiformat /dev/mtd$mtdnum -y | ||||||
|  | 		ubiattach -m "$mtdnum" | ||||||
|  | 		sync | ||||||
|  | 		ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 		[ "$has_env" -gt 0 ] && { | ||||||
|  | 			ubimkvol /dev/$ubidev -n 0 -N ubootenv -s 1MiB | ||||||
|  | 			ubimkvol /dev/$ubidev -n 1 -N ubootenv2 -s 1MiB | ||||||
|  | 		} | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	local kern_ubivol="$( nand_find_volume $ubidev $CI_KERNPART )" | ||||||
|  | 	local root_ubivol="$( nand_find_volume $ubidev $CI_ROOTPART )" | ||||||
|  | 	local data_ubivol="$( nand_find_volume $ubidev rootfs_data )" | ||||||
|  |  | ||||||
|  | 	# remove ubiblock device of rootfs | ||||||
|  | 	local root_ubiblk="ubiblock${root_ubivol:3}" | ||||||
|  | 	if [ "$root_ubivol" -a -e "/dev/$root_ubiblk" ]; then | ||||||
|  | 		echo "removing $root_ubiblk" | ||||||
|  | 		if ! ubiblock -r /dev/$root_ubivol; then | ||||||
|  | 			echo "cannot remove $root_ubiblk" | ||||||
|  | 			return 1; | ||||||
|  | 		fi | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	# kill volumes | ||||||
|  | 	[ "$kern_ubivol" ] && ubirmvol /dev/$ubidev -N $CI_KERNPART || true | ||||||
|  | 	[ "$root_ubivol" ] && ubirmvol /dev/$ubidev -N $CI_ROOTPART || true | ||||||
|  | 	[ "$data_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs_data || true | ||||||
|  |  | ||||||
|  | 	# update kernel | ||||||
|  | 	if [ "$has_kernel" = "1" ]; then | ||||||
|  | 		if ! ubimkvol /dev/$ubidev -N $CI_KERNPART -s $kernel_length; then | ||||||
|  | 			echo "cannot create kernel volume" | ||||||
|  | 			return 1; | ||||||
|  | 		fi | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	# update rootfs | ||||||
|  | 	local root_size_param | ||||||
|  | 	if [ "$rootfs_type" = "ubifs" ]; then | ||||||
|  | 		root_size_param="-m" | ||||||
|  | 	else | ||||||
|  | 		root_size_param="-s $rootfs_length" | ||||||
|  | 	fi | ||||||
|  | 	if ! ubimkvol /dev/$ubidev -N $CI_ROOTPART $root_size_param; then | ||||||
|  | 		echo "cannot create rootfs volume" | ||||||
|  | 		return 1; | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	# create rootfs_data for non-ubifs rootfs | ||||||
|  | 	if [ "$rootfs_type" != "ubifs" ]; then | ||||||
|  | 		if ! ubimkvol /dev/$ubidev -N rootfs_data -m; then | ||||||
|  | 			echo "cannot initialize rootfs_data volume" | ||||||
|  | 			return 1 | ||||||
|  | 		fi | ||||||
|  | 	fi | ||||||
|  | 	sync | ||||||
|  | 	return 0 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | nand_do_upgrade_success() { | ||||||
|  | 	local conf_tar="/tmp/sysupgrade.tgz" | ||||||
|  |  | ||||||
|  | 	sync | ||||||
|  | 	[ -f "$conf_tar" ] && nand_restore_config "$conf_tar" | ||||||
|  | 	echo "sysupgrade successful" | ||||||
|  | 	umount -a | ||||||
|  | 	reboot -f | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # Flash the UBI image to MTD partition | ||||||
|  | nand_upgrade_ubinized() { | ||||||
|  | 	local ubi_file="$1" | ||||||
|  | 	local mtdnum="$(find_mtd_index "$CI_UBIPART")" | ||||||
|  |  | ||||||
|  | 	[ ! "$mtdnum" ] && { | ||||||
|  | 		CI_UBIPART="rootfs" | ||||||
|  | 		mtdnum="$(find_mtd_index "$CI_UBIPART")" | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if [ ! "$mtdnum" ]; then | ||||||
|  | 		echo "cannot find mtd device $CI_UBIPART" | ||||||
|  | 		umount -a | ||||||
|  | 		reboot -f | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	local mtddev="/dev/mtd${mtdnum}" | ||||||
|  | 	ubidetach -p "${mtddev}" || true | ||||||
|  | 	sync | ||||||
|  | 	ubiformat "${mtddev}" -y -f "${ubi_file}" | ||||||
|  | 	ubiattach -p "${mtddev}" | ||||||
|  | 	nand_do_upgrade_success | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # Write the UBIFS image to UBI volume | ||||||
|  | nand_upgrade_ubifs() { | ||||||
|  | 	local rootfs_length=$( (cat $1 | wc -c) 2> /dev/null) | ||||||
|  |  | ||||||
|  | 	nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "0" "0" | ||||||
|  |  | ||||||
|  | 	local ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 	local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)" | ||||||
|  | 	ubiupdatevol /dev/$root_ubivol -s $rootfs_length $1 | ||||||
|  |  | ||||||
|  | 	nand_do_upgrade_success | ||||||
|  | } | ||||||
|  |  | ||||||
|  | nand_upgrade_tar() { | ||||||
|  | 	local tar_file="$1" | ||||||
|  | 	local kernel_mtd="$(find_mtd_index $CI_KERNPART)" | ||||||
|  |  | ||||||
|  | 	local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$') | ||||||
|  | 	board_dir=${board_dir%/} | ||||||
|  |  | ||||||
|  | 	local kernel_length=$( (tar xf $tar_file ${board_dir}/kernel -O | wc -c) 2> /dev/null) | ||||||
|  | 	local rootfs_length=$( (tar xf $tar_file ${board_dir}/root -O | wc -c) 2> /dev/null) | ||||||
|  |  | ||||||
|  | 	local rootfs_type="$(identify_tar "$tar_file" ${board_dir}/root)" | ||||||
|  |  | ||||||
|  | 	local has_kernel=1 | ||||||
|  | 	local has_env=0 | ||||||
|  |  | ||||||
|  | 	[ "$kernel_length" != 0 -a -n "$kernel_mtd" ] && { | ||||||
|  | 		tar xf $tar_file ${board_dir}/kernel -O | mtd write - $CI_KERNPART | ||||||
|  | 	} | ||||||
|  | 	[ "$kernel_length" = 0 -o ! -z "$kernel_mtd" ] && has_kernel=0 | ||||||
|  |  | ||||||
|  | 	nand_upgrade_prepare_ubi "$rootfs_length" "$rootfs_type" "$has_kernel" "$has_env" | ||||||
|  |  | ||||||
|  | 	local ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 	[ "$has_kernel" = "1" ] && { | ||||||
|  | 		local kern_ubivol="$(nand_find_volume $ubidev $CI_KERNPART)" | ||||||
|  | 		tar xf $tar_file ${board_dir}/kernel -O | \ | ||||||
|  | 			ubiupdatevol /dev/$kern_ubivol -s $kernel_length - | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)" | ||||||
|  | 	tar xf $tar_file ${board_dir}/root -O | \ | ||||||
|  | 		ubiupdatevol /dev/$root_ubivol -s $rootfs_length - | ||||||
|  |  | ||||||
|  | 	nand_do_upgrade_success | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # Recognize type of passed file and start the upgrade process | ||||||
|  | nand_do_upgrade() { | ||||||
|  | 	local file_type=$(identify $1) | ||||||
|  |  | ||||||
|  | 	[ ! "$(find_mtd_index "$CI_UBIPART")" ] && CI_UBIPART="rootfs" | ||||||
|  |  | ||||||
|  | 	case "$file_type" in | ||||||
|  | 		"ubi")		nand_upgrade_ubinized $1;; | ||||||
|  | 		"ubifs")	nand_upgrade_ubifs $1;; | ||||||
|  | 		*)		nand_upgrade_tar $1;; | ||||||
|  | 	esac | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # Check if passed file is a valid one for NAND sysupgrade. Currently it accepts | ||||||
|  | # 3 types of files: | ||||||
|  | # 1) UBI - should contain an ubinized image, header is checked for the proper | ||||||
|  | #    MAGIC | ||||||
|  | # 2) UBIFS - should contain UBIFS partition that will replace "rootfs" volume, | ||||||
|  | #    header is checked for the proper MAGIC | ||||||
|  | # 3) TAR - archive has to include "sysupgrade-BOARD" directory with a non-empty | ||||||
|  | #    "CONTROL" file (at this point its content isn't verified) | ||||||
|  | # | ||||||
|  | # You usually want to call this function in platform_check_image. | ||||||
|  | # | ||||||
|  | # $(1): board name, used in case of passing TAR file | ||||||
|  | # $(2): file to be checked | ||||||
|  | nand_do_platform_check() { | ||||||
|  | 	local board_name="$1" | ||||||
|  | 	local tar_file="$2" | ||||||
|  | 	local control_length=$( (tar xf $tar_file sysupgrade-$board_name/CONTROL -O | wc -c) 2> /dev/null) | ||||||
|  | 	local file_type="$(identify $2)" | ||||||
|  |  | ||||||
|  | 	[ "$control_length" = 0 -a "$file_type" != "ubi" -a "$file_type" != "ubifs" ] && { | ||||||
|  | 		echo "Invalid sysupgrade file." | ||||||
|  | 		return 1 | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return 0 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | dual_boot_upgrade_prepare_ubi() { | ||||||
|  | 	local kernel_vol_name="$1" | ||||||
|  | 	local rootfs_vol_name="$2" | ||||||
|  | 	local kernel_length="$3" | ||||||
|  | 	local rootfs_length="$4" | ||||||
|  | 	local reserve_rootfs_data="$5" | ||||||
|  | 	local conf_tar="/tmp/sysupgrade.tgz" | ||||||
|  |  | ||||||
|  | 	local mtdnum="$( find_mtd_index "$CI_UBIPART" )" | ||||||
|  | 	if [ ! "$mtdnum" ]; then | ||||||
|  | 		echo "cannot find ubi mtd partition $CI_UBIPART" | ||||||
|  | 		return 1 | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	local ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 	if [ ! "$ubidev" ]; then | ||||||
|  | 		ubiattach -m "$mtdnum" | ||||||
|  | 		sync | ||||||
|  | 		ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	if [ ! "$ubidev" ]; then | ||||||
|  | 		ubiformat /dev/mtd$mtdnum -y | ||||||
|  | 		ubiattach -m "$mtdnum" | ||||||
|  | 		sync | ||||||
|  | 		ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  | 		ubimkvol /dev/$ubidev -n 0 -N u-boot-env -s 512KiB | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	#local rootfs_data_vol_name=$(cat /sys/module/boot_param/parameters/rootfs_data_part 2>/dev/null) | ||||||
|  | 	local rootfs_data_vol_name=$(get_boot_param "boot_param.rootfs_data_part") | ||||||
|  | 	 | ||||||
|  | 	local kern_ubivol="$( nand_find_volume $ubidev $kernel_vol_name )" | ||||||
|  | 	local root_ubivol="$( nand_find_volume $ubidev $rootfs_vol_name )" | ||||||
|  | 	local data_ubivol="$( nand_find_volume $ubidev $rootfs_data_vol_name )" | ||||||
|  |  | ||||||
|  | 	# remove ubiblock device of rootfs | ||||||
|  | 	local root_ubiblk="ubiblock${root_ubivol:3}" | ||||||
|  | 	if [ "$root_ubivol" -a -e "/dev/$root_ubiblk" ]; then | ||||||
|  | 		echo "removing $root_ubiblk" | ||||||
|  | 		if ! ubiblock -r /dev/$root_ubivol; then | ||||||
|  | 			echo "cannot remove $root_ubiblk" | ||||||
|  | 			return 1; | ||||||
|  | 		fi | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	# kill volumes | ||||||
|  | 	[ "$kern_ubivol" ] && ubirmvol /dev/$ubidev -N $kernel_vol_name || true | ||||||
|  | 	[ "$root_ubivol" ] && ubirmvol /dev/$ubidev -N $rootfs_vol_name || true | ||||||
|  |  | ||||||
|  | 	# update kernel | ||||||
|  | 	if ! ubimkvol /dev/$ubidev -N $kernel_vol_name -s $kernel_length; then | ||||||
|  | 		echo "cannot create kernel volume" | ||||||
|  | 		return 1; | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	# update rootfs | ||||||
|  | 	if ! ubimkvol /dev/$ubidev -N $rootfs_vol_name -s $rootfs_length; then | ||||||
|  | 		echo "cannot create rootfs volume" | ||||||
|  | 		return 1; | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	if [ x"${reserve_rootfs_data}" = xY ] && [ -f "$conf_tar" ]; then | ||||||
|  | 		# Do not touch rootfs_data | ||||||
|  | 		sync | ||||||
|  | 		return 0 | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	# 'format' rootfs_data volume | ||||||
|  | 	[ "$data_ubivol" ] && { | ||||||
|  | 		local rootfs_data_length=$(cat /sys/class/ubi/$data_ubivol/data_bytes) | ||||||
|  |  | ||||||
|  | 		# kill rootfs_data volume | ||||||
|  | 		ubirmvol /dev/$ubidev -N $rootfs_data_vol_name || true | ||||||
|  |  | ||||||
|  | 		# update rootfs_data | ||||||
|  | 		if ! ubimkvol /dev/$ubidev -N $rootfs_data_vol_name -s $rootfs_data_length; then | ||||||
|  | 			echo "cannot create $rootfs_data_vol_name volume" | ||||||
|  | 		fi | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	sync | ||||||
|  | 	return 0 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | ubi_dual_boot_upgrade_tar() { | ||||||
|  | 	local tar_file="$1" | ||||||
|  | 	local board_dir=$(tar tf ${tar_file} | grep -m 1 '^sysupgrade-.*/$') | ||||||
|  | 	#local reserve_rootfs_data=$(cat /sys/module/boot_param/parameters/reserve_rootfs_data 2>/dev/null) | ||||||
|  | 	local reserve_rootfs_data=$(get_boot_param "boot_param.reserve_rootfs_data") | ||||||
|  | 	board_dir=${board_dir%/} | ||||||
|  |  | ||||||
|  | 	#kernel_vol_name=$(cat /sys/module/boot_param/parameters/upgrade_kernel_part 2>/dev/null) | ||||||
|  | 	kernel_vol_name=$(get_boot_param "boot_param.upgrade_kernel_part") | ||||||
|  | 	[ -z "${kernel_vol_name}" -o $? -ne 0 ] && return 1 | ||||||
|  |  | ||||||
|  | 	#rootfs_vol_name=$(cat /sys/module/boot_param/parameters/upgrade_rootfs_part 2>/dev/null) | ||||||
|  | 	rootfs_vol_name=$(get_boot_param "boot_param.upgrade_rootfs_part") | ||||||
|  | 	[ -z "${rootfs_vol_name}" -o $? -ne 0 ] && return 1 | ||||||
|  |  | ||||||
|  | 	local kernel_length=$( (tar xf ${tar_file} ${board_dir}/kernel -O | wc -c) 2> /dev/null) | ||||||
|  | 	local rootfs_length=$( (tar xf ${tar_file} ${board_dir}/root -O | wc -c) 2> /dev/null) | ||||||
|  | 	echo "kernel_vol_name=$kernel_vol_name,rootfs_vol_name=$rootfs_vol_name,kernel_length=$kernel_length,rootfs_length=$rootfs_length,reserve_rootfs_data=$reserve_rootfs_data" | ||||||
|  | 	dual_boot_upgrade_prepare_ubi "${kernel_vol_name}" "${rootfs_vol_name}" \ | ||||||
|  | 				      "${kernel_length}" "${rootfs_length}" \ | ||||||
|  | 				      "${reserve_rootfs_data}" | ||||||
|  |  | ||||||
|  | 	local ubidev="$( nand_find_ubi "$CI_UBIPART" )" | ||||||
|  |  | ||||||
|  | 	[ "${kernel_length}" != 0 ] && { | ||||||
|  | 		local kern_ubivol="$(nand_find_volume $ubidev ${kernel_vol_name})" | ||||||
|  | 		tar xf ${tar_file} ${board_dir}/kernel -O | \ | ||||||
|  | 			ubiupdatevol /dev/${kern_ubivol} -s ${kernel_length} - | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	[ "${rootfs_length}" != 0 ] && { | ||||||
|  | 		local root_ubivol="$(nand_find_volume $ubidev ${rootfs_vol_name})" | ||||||
|  | 		tar xf ${tar_file} ${board_dir}/root -O | \ | ||||||
|  | 			ubiupdatevol /dev/${root_ubivol} -s ${rootfs_length} - | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	#upgrade_image_slot=$(cat /sys/module/boot_param/parameters/upgrade_image_slot 2>/dev/null) | ||||||
|  | 	upgrade_image_slot=$(get_boot_param "boot_param.upgrade_image_slot") | ||||||
|  | 	[ -n "${upgrade_image_slot}" ] && { | ||||||
|  | 		echo "Set new boot image slot to ${upgrade_image_slot}" | ||||||
|  | 		# Force the creation of fw_printenv.lock | ||||||
|  | 		mkdir -p /var/lock | ||||||
|  | 		touch /var/lock/fw_printenv.lock | ||||||
|  | 		fw_setenv "dual_boot.current_slot" "${upgrade_image_slot}" | ||||||
|  | 		fw_setenv "dual_boot.slot_${upgrade_image_slot}_invalid" "0" | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if [ x"${reserve_rootfs_data}" != xY ]; then | ||||||
|  | 		# do normal upgrade flow | ||||||
|  | 		nand_do_upgrade_success | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	# Do not touch rootfs_data | ||||||
|  | 	sync | ||||||
|  |  | ||||||
|  | 	echo "sysupgrade successful" | ||||||
|  | 	umount -a | ||||||
|  | 	reboot -f | ||||||
|  | } | ||||||
|  |  | ||||||
|  | ubi_do_upgrade() { | ||||||
|  | 	#local dual_boot=$(cat /sys/module/boot_param/parameters/dual_boot 2>/dev/null) | ||||||
|  | 	local dual_boot=$(get_boot_param "boot_param.dual_boot") | ||||||
|  | 	local file_type=$(identify $1) | ||||||
|  |  | ||||||
|  | 	if [ -b /dev/dm-0 ]; then | ||||||
|  | 		v "Detach all device mapper devices" | ||||||
|  | 		dmsetup remove_all | ||||||
|  | 	fi | ||||||
|  | 	echo "dual_boot=$dual_boot file_type=$file_type" | ||||||
|  | 	if [ x"${dual_boot}" != xY ]; then | ||||||
|  | 		nand_do_upgrade "$1" | ||||||
|  | 		return | ||||||
|  | 	fi | ||||||
|  |  | ||||||
|  | 	case "$file_type" in | ||||||
|  | 		"ubi")		v "Unsupported firmware type: ubinized";; | ||||||
|  | 		"ubifs")	v "Unsupported firmware type: ubifs";; | ||||||
|  | 		*)		ubi_dual_boot_upgrade_tar $1;; | ||||||
|  | 	esac | ||||||
|  | } | ||||||
|  |  | ||||||
|  | ubi_do_upgrade "$1" | ||||||
							
								
								
									
										677
									
								
								patches/0072-add-sonicfi-rap630w-211g.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										677
									
								
								patches/0072-add-sonicfi-rap630w-211g.patch
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,677 @@ | |||||||
|  | From eea2581a6ab99f62ce12137cc69e317d8de67215 Mon Sep 17 00:00:00 2001 | ||||||
|  | From: Your Name <you@example.com> | ||||||
|  | Date: Wed, 7 Aug 2024 15:52:58 +0800 | ||||||
|  | Subject: [PATCH] add sonicfi rap630w 211g | ||||||
|  |  | ||||||
|  | Signed-off-by: Your Name <you@example.com> | ||||||
|  | --- | ||||||
|  |  include/image-commands.mk                   |  27 ++ | ||||||
|  |  package/base-files/files/lib/upgrade/stage2 |   2 +- | ||||||
|  |  scripts/mkits_sonicfi_rap630w_211g.sh       | 237 ++++++++++++++++ | ||||||
|  |  tools/Makefile                              |   1 + | ||||||
|  |  tools/crc32sum/Makefile                     |  23 ++ | ||||||
|  |  tools/crc32sum/src/Makefile                 |  18 ++ | ||||||
|  |  tools/crc32sum/src/crc32sum.c               | 282 ++++++++++++++++++++ | ||||||
|  |  7 files changed, 589 insertions(+), 1 deletion(-) | ||||||
|  |  create mode 100755 scripts/mkits_sonicfi_rap630w_211g.sh | ||||||
|  |  create mode 100644 tools/crc32sum/Makefile | ||||||
|  |  create mode 100644 tools/crc32sum/src/Makefile | ||||||
|  |  create mode 100644 tools/crc32sum/src/crc32sum.c | ||||||
|  |  | ||||||
|  | diff --git a/include/image-commands.mk b/include/image-commands.mk | ||||||
|  | index dc6ee6e7c1..0013eeb540 100644 | ||||||
|  | --- a/include/image-commands.mk | ||||||
|  | +++ b/include/image-commands.mk | ||||||
|  | @@ -291,6 +291,32 @@ define Build/initrd_compression | ||||||
|  |  	$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_ZSTD),.zstd) | ||||||
|  |  endef | ||||||
|  |   | ||||||
|  | +ifeq ($(CONFIG_TARGET_mediatek_mt7981_DEVICE_sonicfi_rap630w_211g),y) | ||||||
|  | +define Build/fit | ||||||
|  | +	$(TOPDIR)/scripts/mkits_sonicfi_rap630w_211g.sh \ | ||||||
|  | +		-D $(DEVICE_NAME) -o $@.its -k $@ \ | ||||||
|  | +		-C $(word 1,$(1)) \ | ||||||
|  | +		$(if $(word 2,$(1)),\ | ||||||
|  | +			$(if $(findstring 11,$(if $(DEVICE_DTS_OVERLAY),1)$(if $(findstring $(KERNEL_BUILD_DIR)/image-,$(word 2,$(1))),,1)), \ | ||||||
|  | +				-d $(KERNEL_BUILD_DIR)/image-$$(basename $(word 2,$(1))), \ | ||||||
|  | +				-d $(word 2,$(1)))) \ | ||||||
|  | +		$(if $(findstring with-rootfs,$(word 3,$(1))),-r $(IMAGE_ROOTFS)) \ | ||||||
|  | +		$(if $(findstring with-initrd,$(word 3,$(1))), \ | ||||||
|  | +			$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS_SEPARATE), \ | ||||||
|  | +				-i $(KERNEL_BUILD_DIR)/initrd.cpio$(strip $(call Build/initrd_compression)))) \ | ||||||
|  | +		-a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \ | ||||||
|  | +		$(if $(DEVICE_FDT_NUM),-n $(DEVICE_FDT_NUM)) \ | ||||||
|  | +		$(if $(DEVICE_DTS_DELIMITER),-l $(DEVICE_DTS_DELIMITER)) \ | ||||||
|  | +		$(if $(DEVICE_DTS_LOADADDR),-s $(DEVICE_DTS_LOADADDR)) \ | ||||||
|  | +		$(if $(DEVICE_DTS_OVERLAY),$(foreach dtso,$(DEVICE_DTS_OVERLAY), -O $(dtso):$(KERNEL_BUILD_DIR)/image-$(dtso).dtbo)) \ | ||||||
|  | +		-c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config-1") \ | ||||||
|  | +		-A $(LINUX_KARCH) -v $(LINUX_VERSION) \ | ||||||
|  | +		$(if $(CONFIG_TARGET_ROOTFS_SQUASHFS),-r $(ROOTFS/squashfs/$(DEVICE_NAME))) | ||||||
|  | +	PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage $(if $(findstring external,$(word 3,$(1))),\ | ||||||
|  | +		-E -B 0x1000 $(if $(findstring static,$(word 3,$(1))),-p 0x1000)) -f $@.its $@.new | ||||||
|  | +	@mv $@.new $@ | ||||||
|  | +endef | ||||||
|  | +else | ||||||
|  |  define Build/fit | ||||||
|  |  	$(TOPDIR)/scripts/mkits.sh \ | ||||||
|  |  		-D $(DEVICE_NAME) -o $@.its -k $@ \ | ||||||
|  | @@ -314,6 +340,7 @@ define Build/fit | ||||||
|  |  		-E -B 0x1000 $(if $(findstring static,$(word 3,$(1))),-p 0x1000)) -f $@.its $@.new | ||||||
|  |  	@mv $@.new $@ | ||||||
|  |  endef | ||||||
|  | +endif | ||||||
|  |   | ||||||
|  |  define Build/libdeflate-gzip | ||||||
|  |  	$(STAGING_DIR_HOST)/bin/libdeflate-gzip -f -12 -c $@ $(1) > $@.new | ||||||
|  | diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 | ||||||
|  | index 5ce0b3549c..2f1cb45b6e 100755 | ||||||
|  | --- a/package/base-files/files/lib/upgrade/stage2 | ||||||
|  | +++ b/package/base-files/files/lib/upgrade/stage2 | ||||||
|  | @@ -11,7 +11,7 @@ export VERBOSE=1 | ||||||
|  |  export CONFFILES=/tmp/sysupgrade.conffiles | ||||||
|  |   | ||||||
|  |  RAMFS_COPY_BIN=		# extra programs for temporary ramfs root | ||||||
|  | -RAMFS_COPY_DATA=	# extra data files | ||||||
|  | +RAMFS_COPY_DATA="/lib/upgrade/sonicfi/*.sh"     # extra data files | ||||||
|  |   | ||||||
|  |  include /lib/upgrade | ||||||
|  |   | ||||||
|  | diff --git a/scripts/mkits_sonicfi_rap630w_211g.sh b/scripts/mkits_sonicfi_rap630w_211g.sh | ||||||
|  | new file mode 100755 | ||||||
|  | index 0000000000..35f2d00767 | ||||||
|  | --- /dev/null | ||||||
|  | +++ b/scripts/mkits_sonicfi_rap630w_211g.sh | ||||||
|  | @@ -0,0 +1,237 @@ | ||||||
|  | +#!/bin/sh | ||||||
|  | +# | ||||||
|  | +# Licensed under the terms of the GNU GPL License version 2 or later. | ||||||
|  | +# | ||||||
|  | +# Author: Peter Tyser <ptyser@xes-inc.com> | ||||||
|  | +# | ||||||
|  | +# U-Boot firmware supports the booting of images in the Flattened Image | ||||||
|  | +# Tree (FIT) format.  The FIT format uses a device tree structure to | ||||||
|  | +# describe a kernel image, device tree blob, ramdisk, etc.  This script | ||||||
|  | +# creates an Image Tree Source (.its file) which can be passed to the | ||||||
|  | +# 'mkimage' utility to generate an Image Tree Blob (.itb file).  The .itb | ||||||
|  | +# file can then be booted by U-Boot (or other bootloaders which support | ||||||
|  | +# FIT images).  See doc/uImage.FIT/howto.txt in U-Boot source code for | ||||||
|  | +# additional information on FIT images. | ||||||
|  | +# | ||||||
|  | + | ||||||
|  | +usage() { | ||||||
|  | +	printf "Usage: %s -A arch -C comp -a addr -e entry" "$(basename "$0")" | ||||||
|  | +	printf " -v version -k kernel [-D name -n address -d dtb] -o its_file" | ||||||
|  | + | ||||||
|  | +	printf "\n\t-A ==> set architecture to 'arch'" | ||||||
|  | +	printf "\n\t-C ==> set compression type 'comp'" | ||||||
|  | +	printf "\n\t-c ==> set config name 'config'" | ||||||
|  | +	printf "\n\t-a ==> set load address to 'addr' (hex)" | ||||||
|  | +	printf "\n\t-e ==> set entry point to 'entry' (hex)" | ||||||
|  | +	printf "\n\t-f ==> set device tree compatible string" | ||||||
|  | +	printf "\n\t-i ==> include initrd Blob 'initrd'" | ||||||
|  | +	printf "\n\t-v ==> set kernel version to 'version'" | ||||||
|  | +	printf "\n\t-k ==> include kernel image 'kernel'" | ||||||
|  | +	printf "\n\t-D ==> human friendly Device Tree Blob 'name'" | ||||||
|  | +	printf "\n\t-n ==> fdt unit-address 'address'" | ||||||
|  | +	printf "\n\t-d ==> include Device Tree Blob 'dtb'" | ||||||
|  | +	printf "\n\t-r ==> include RootFS blob 'rootfs'" | ||||||
|  | +	printf "\n\t-H ==> specify hash algo instead of SHA1" | ||||||
|  | +	printf "\n\t-l ==> legacy mode character (@ etc otherwise -)" | ||||||
|  | +	printf "\n\t-o ==> create output file 'its_file'" | ||||||
|  | +	printf "\n\t-O ==> create config with dt overlay 'name:dtb'" | ||||||
|  | +	printf "\n\t-s ==> set FDT load address to 'addr' (hex)" | ||||||
|  | +	printf "\n\t\t(can be specified more than once)\n" | ||||||
|  | +	exit 1 | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +REFERENCE_CHAR='-' | ||||||
|  | +FDTNUM=1 | ||||||
|  | +ROOTFSNUM=1 | ||||||
|  | +INITRDNUM=1 | ||||||
|  | +HASH=sha1 | ||||||
|  | +LOADABLES= | ||||||
|  | +DTOVERLAY= | ||||||
|  | +DTADDR= | ||||||
|  | + | ||||||
|  | +while getopts ":A:a:c:C:D:d:e:f:i:k:l:n:o:O:v:r:s:H:" OPTION | ||||||
|  | +do | ||||||
|  | +	case $OPTION in | ||||||
|  | +		A ) ARCH=$OPTARG;; | ||||||
|  | +		a ) LOAD_ADDR=$OPTARG;; | ||||||
|  | +		c ) CONFIG=$OPTARG;; | ||||||
|  | +		C ) COMPRESS=$OPTARG;; | ||||||
|  | +		D ) DEVICE=$OPTARG;; | ||||||
|  | +		d ) DTB=$OPTARG;; | ||||||
|  | +		e ) ENTRY_ADDR=$OPTARG;; | ||||||
|  | +		f ) COMPATIBLE=$OPTARG;; | ||||||
|  | +		i ) INITRD=$OPTARG;; | ||||||
|  | +		k ) KERNEL=$OPTARG;; | ||||||
|  | +		l ) REFERENCE_CHAR=$OPTARG;; | ||||||
|  | +		n ) FDTNUM=$OPTARG;; | ||||||
|  | +		o ) OUTPUT=$OPTARG;; | ||||||
|  | +		O ) DTOVERLAY="$DTOVERLAY ${OPTARG}";; | ||||||
|  | +		r ) ROOTFS=$OPTARG;; | ||||||
|  | +		s ) FDTADDR=$OPTARG;; | ||||||
|  | +		H ) HASH=$OPTARG;; | ||||||
|  | +		v ) VERSION=$OPTARG;; | ||||||
|  | +		* ) echo "Invalid option passed to '$0' (options:$*)" | ||||||
|  | +		usage;; | ||||||
|  | +	esac | ||||||
|  | +done | ||||||
|  | + | ||||||
|  | +# Make sure user entered all required parameters | ||||||
|  | +if [ -z "${ARCH}" ] || [ -z "${COMPRESS}" ] || [ -z "${LOAD_ADDR}" ] || \ | ||||||
|  | +	[ -z "${ENTRY_ADDR}" ] || [ -z "${VERSION}" ] || [ -z "${KERNEL}" ] || \ | ||||||
|  | +	[ -z "${OUTPUT}" ] || [ -z "${CONFIG}" ]; then | ||||||
|  | +	usage | ||||||
|  | +fi | ||||||
|  | + | ||||||
|  | +ARCH_UPPER=$(echo "$ARCH" | tr '[:lower:]' '[:upper:]') | ||||||
|  | + | ||||||
|  | +if [ -n "${COMPATIBLE}" ]; then | ||||||
|  | +	COMPATIBLE_PROP="compatible = \"${COMPATIBLE}\";" | ||||||
|  | +fi | ||||||
|  | + | ||||||
|  | +[ "$FDTADDR" ] && { | ||||||
|  | +	DTADDR="$FDTADDR" | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +# Conditionally create fdt information | ||||||
|  | +if [ -n "${DTB}" ]; then | ||||||
|  | +	FDT_NODE=" | ||||||
|  | +		fdt${REFERENCE_CHAR}$FDTNUM { | ||||||
|  | +			description = \"${ARCH_UPPER} OpenWrt ${DEVICE} device tree blob\"; | ||||||
|  | +			${COMPATIBLE_PROP} | ||||||
|  | +			data = /incbin/(\"${DTB}\"); | ||||||
|  | +			type = \"flat_dt\"; | ||||||
|  | +			${DTADDR:+load = <${DTADDR}>;} | ||||||
|  | +			arch = \"${ARCH}\"; | ||||||
|  | +			compression = \"none\"; | ||||||
|  | +			hash${REFERENCE_CHAR}1 { | ||||||
|  | +				algo = \"crc32\"; | ||||||
|  | +			}; | ||||||
|  | +			hash${REFERENCE_CHAR}2 { | ||||||
|  | +				algo = \"${HASH}\"; | ||||||
|  | +			}; | ||||||
|  | +		}; | ||||||
|  | +" | ||||||
|  | +	FDT_PROP="fdt = \"fdt${REFERENCE_CHAR}$FDTNUM\";" | ||||||
|  | +fi | ||||||
|  | + | ||||||
|  | +if [ -n "${INITRD}" ]; then | ||||||
|  | +	INITRD_NODE=" | ||||||
|  | +		initrd${REFERENCE_CHAR}$INITRDNUM { | ||||||
|  | +			description = \"${ARCH_UPPER} OpenWrt ${DEVICE} initrd\"; | ||||||
|  | +			${COMPATIBLE_PROP} | ||||||
|  | +			data = /incbin/(\"${INITRD}\"); | ||||||
|  | +			type = \"ramdisk\"; | ||||||
|  | +			arch = \"${ARCH}\"; | ||||||
|  | +			os = \"linux\"; | ||||||
|  | +			hash${REFERENCE_CHAR}1 { | ||||||
|  | +				algo = \"crc32\"; | ||||||
|  | +			}; | ||||||
|  | +			hash${REFERENCE_CHAR}2 { | ||||||
|  | +				algo = \"${HASH}\"; | ||||||
|  | +			}; | ||||||
|  | +		}; | ||||||
|  | +" | ||||||
|  | +	INITRD_PROP="ramdisk=\"initrd${REFERENCE_CHAR}${INITRDNUM}\";" | ||||||
|  | +fi | ||||||
|  | + | ||||||
|  | + | ||||||
|  | +if [ -n "${ROOTFS}" ]; then | ||||||
|  | +	ROOTFS_SIZE=$(stat -c %s ${ROOTFS}) | ||||||
|  | +	ROOTFS_SHA1=$(sha1sum ${ROOTFS} | awk '{print "<0x"substr($0,1,8) " 0x"substr($0,9,8) " 0x"substr($0,17,8) " 0x"substr($0,25,8) " 0x"substr($0,33,8) ">"}') | ||||||
|  | +	ROOTFS_CRC32=$(crc32sum ${ROOTFS}) | ||||||
|  | +	ROOTFS_NODE=" | ||||||
|  | +		rootfs { | ||||||
|  | +				size = <${ROOTFS_SIZE}>; | ||||||
|  | +				hash-1 { | ||||||
|  | +					value = <0x${ROOTFS_CRC32}>; | ||||||
|  | +					algo = \"crc32\"; | ||||||
|  | +					}; | ||||||
|  | +				hash-2 { | ||||||
|  | +					value = ${ROOTFS_SHA1}; | ||||||
|  | +					algo = \"sha1\"; | ||||||
|  | +					}; | ||||||
|  | +			}; | ||||||
|  | +" | ||||||
|  | +fi | ||||||
|  | + | ||||||
|  | +# add DT overlay blobs | ||||||
|  | +FDTOVERLAY_NODE="" | ||||||
|  | +OVCONFIGS="" | ||||||
|  | +[ "$DTOVERLAY" ] && for overlay in $DTOVERLAY ; do | ||||||
|  | +	overlay_blob=${overlay##*:} | ||||||
|  | +	ovname=${overlay%%:*} | ||||||
|  | +	ovnode="fdt-$ovname" | ||||||
|  | +	ovsize=$(wc -c "$overlay_blob" | awk '{print $1}') | ||||||
|  | +	echo "$ovname ($overlay_blob) : $ovsize" >&2 | ||||||
|  | +	FDTOVERLAY_NODE="$FDTOVERLAY_NODE | ||||||
|  | + | ||||||
|  | +		$ovnode { | ||||||
|  | +			description = \"${ARCH_UPPER} OpenWrt ${DEVICE} device tree overlay $ovname\"; | ||||||
|  | +			${COMPATIBLE_PROP} | ||||||
|  | +			data = /incbin/(\"${overlay_blob}\"); | ||||||
|  | +			type = \"flat_dt\"; | ||||||
|  | +			arch = \"${ARCH}\"; | ||||||
|  | +			compression = \"none\"; | ||||||
|  | +			hash${REFERENCE_CHAR}1 { | ||||||
|  | +				algo = \"crc32\"; | ||||||
|  | +			}; | ||||||
|  | +			hash${REFERENCE_CHAR}2 { | ||||||
|  | +				algo = \"${HASH}\"; | ||||||
|  | +			}; | ||||||
|  | +		}; | ||||||
|  | +" | ||||||
|  | +	OVCONFIGS="$OVCONFIGS | ||||||
|  | + | ||||||
|  | +		$ovname { | ||||||
|  | +			description = \"OpenWrt ${DEVICE} overlay $ovname\"; | ||||||
|  | +			fdt = \"$ovnode\"; | ||||||
|  | +			${COMPATIBLE_PROP} | ||||||
|  | +		}; | ||||||
|  | +	" | ||||||
|  | +done | ||||||
|  | + | ||||||
|  | +# Create a default, fully populated DTS file | ||||||
|  | +DATA="/dts-v1/; | ||||||
|  | + | ||||||
|  | +/ { | ||||||
|  | +	description = \"${ARCH_UPPER} OpenWrt FIT (Flattened Image Tree)\"; | ||||||
|  | +	#address-cells = <1>; | ||||||
|  | + | ||||||
|  | +	images { | ||||||
|  | +		kernel${REFERENCE_CHAR}1 { | ||||||
|  | +			description = \"${ARCH_UPPER} OpenWrt Linux-${VERSION}\"; | ||||||
|  | +			data = /incbin/(\"${KERNEL}\"); | ||||||
|  | +			type = \"kernel\"; | ||||||
|  | +			arch = \"${ARCH}\"; | ||||||
|  | +			os = \"linux\"; | ||||||
|  | +			compression = \"${COMPRESS}\"; | ||||||
|  | +			load = <${LOAD_ADDR}>; | ||||||
|  | +			entry = <${ENTRY_ADDR}>; | ||||||
|  | +			hash${REFERENCE_CHAR}1 { | ||||||
|  | +				algo = \"crc32\"; | ||||||
|  | +			}; | ||||||
|  | +			hash${REFERENCE_CHAR}2 { | ||||||
|  | +				algo = \"$HASH\"; | ||||||
|  | +			}; | ||||||
|  | +		}; | ||||||
|  | +${INITRD_NODE} | ||||||
|  | +${FDT_NODE} | ||||||
|  | +${FDTOVERLAY_NODE} | ||||||
|  | +	}; | ||||||
|  | +${ROOTFS_NODE} | ||||||
|  | +	configurations { | ||||||
|  | +		default = \"${CONFIG}\"; | ||||||
|  | +		${CONFIG} { | ||||||
|  | +			description = \"OpenWrt ${DEVICE}\"; | ||||||
|  | +			kernel = \"kernel${REFERENCE_CHAR}1\"; | ||||||
|  | +			${FDT_PROP} | ||||||
|  | +			${LOADABLES:+loadables = ${LOADABLES};} | ||||||
|  | +			${COMPATIBLE_PROP} | ||||||
|  | +			${INITRD_PROP} | ||||||
|  | +		}; | ||||||
|  | +		${OVCONFIGS} | ||||||
|  | +	}; | ||||||
|  | +};" | ||||||
|  | + | ||||||
|  | +# Write .its file to disk | ||||||
|  | +echo "$DATA" > "${OUTPUT}" | ||||||
|  | diff --git a/tools/Makefile b/tools/Makefile | ||||||
|  | index 40c3ec1ab0..6c7abaaf9c 100644 | ||||||
|  | --- a/tools/Makefile | ||||||
|  | +++ b/tools/Makefile | ||||||
|  | @@ -68,6 +68,7 @@ tools-y += sstrip | ||||||
|  |  tools-y += zip | ||||||
|  |  tools-y += zlib | ||||||
|  |  tools-y += zstd | ||||||
|  | +tools-y += crc32sum | ||||||
|  |  tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS),y) += liblzo | ||||||
|  |  tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_B43_TOOLS),y) += b43-tools | ||||||
|  |  tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_BZIP2_TOOLS),y) += bzip2 | ||||||
|  | diff --git a/tools/crc32sum/Makefile b/tools/crc32sum/Makefile | ||||||
|  | new file mode 100644 | ||||||
|  | index 0000000000..bc13ecf92b | ||||||
|  | --- /dev/null | ||||||
|  | +++ b/tools/crc32sum/Makefile | ||||||
|  | @@ -0,0 +1,23 @@ | ||||||
|  | +# | ||||||
|  | +# Copyright (C) 2021 MediaTek Inc. All rights reserved. | ||||||
|  | +# | ||||||
|  | +# This is free software, licensed under the GNU General Public License v2. | ||||||
|  | +# See /LICENSE for more information. | ||||||
|  | +# | ||||||
|  | +include $(TOPDIR)/rules.mk | ||||||
|  | + | ||||||
|  | +PKG_NAME:=crc32sum | ||||||
|  | +PKG_VERSION:=1.0 | ||||||
|  | + | ||||||
|  | +include $(INCLUDE_DIR)/host-build.mk | ||||||
|  | + | ||||||
|  | +define Host/Prepare | ||||||
|  | +	mkdir -p $(HOST_BUILD_DIR) | ||||||
|  | +	$(CP) -a ./src/* $(HOST_BUILD_DIR)/ | ||||||
|  | +endef | ||||||
|  | + | ||||||
|  | +define Host/Install | ||||||
|  | +	$(INSTALL_BIN) $(HOST_BUILD_DIR)/crc32sum $(STAGING_DIR_HOST)/bin/ | ||||||
|  | +endef | ||||||
|  | + | ||||||
|  | +$(eval $(call HostBuild)) | ||||||
|  | diff --git a/tools/crc32sum/src/Makefile b/tools/crc32sum/src/Makefile | ||||||
|  | new file mode 100644 | ||||||
|  | index 0000000000..7428ba2f54 | ||||||
|  | --- /dev/null | ||||||
|  | +++ b/tools/crc32sum/src/Makefile | ||||||
|  | @@ -0,0 +1,18 @@ | ||||||
|  | +# | ||||||
|  | +# Copyright (C) 2021 MediaTek Inc. All rights reserved. | ||||||
|  | +# | ||||||
|  | +# This is free software, licensed under the GNU General Public License v2. | ||||||
|  | +# See /LICENSE for more information. | ||||||
|  | +# | ||||||
|  | + | ||||||
|  | +all: crc32sum | ||||||
|  | + | ||||||
|  | +crc32sum: crc32sum.c | ||||||
|  | +	$(CC) $(CFLAGS) -O2 -ggdb -MD -o $@ $< $(LDFLAGS) | ||||||
|  | + | ||||||
|  | +clean: | ||||||
|  | +	rm -f crc32sum crc32sum.d | ||||||
|  | + | ||||||
|  | +.PHONY: clean | ||||||
|  | + | ||||||
|  | +-include crc32sum.d | ||||||
|  | diff --git a/tools/crc32sum/src/crc32sum.c b/tools/crc32sum/src/crc32sum.c | ||||||
|  | new file mode 100644 | ||||||
|  | index 0000000000..381c7a95a7 | ||||||
|  | --- /dev/null | ||||||
|  | +++ b/tools/crc32sum/src/crc32sum.c | ||||||
|  | @@ -0,0 +1,282 @@ | ||||||
|  | +// SPDX-License-Identifier: GPL-2.0 | ||||||
|  | +/* | ||||||
|  | + * Copyright (C) 2021 MediaTek Inc. All Rights Reserved. | ||||||
|  | + * | ||||||
|  | + * Author: Weijie Gao <weijie.gao@mediatek.com> | ||||||
|  | + */ | ||||||
|  | +#include <stdio.h> | ||||||
|  | +#include <stdarg.h> | ||||||
|  | +#include <stdint.h> | ||||||
|  | +#include <stdlib.h> | ||||||
|  | +#include <stdbool.h> | ||||||
|  | +#include <string.h> | ||||||
|  | +#include <ctype.h> | ||||||
|  | +#include <errno.h> | ||||||
|  | +#include <getopt.h> | ||||||
|  | + | ||||||
|  | +#ifdef _WIN32 | ||||||
|  | +#include <io.h> | ||||||
|  | +#include <fcntl.h> | ||||||
|  | +#define SET_BINARY_MODE(_f)		_setmode(_fileno(_f, O_BINARY) | ||||||
|  | +#else | ||||||
|  | +#define SET_BINARY_MODE(_f)		((void)0) | ||||||
|  | +#endif | ||||||
|  | + | ||||||
|  | +#define CRC32_LE_POLY_DEFAULT		0xedb88320 | ||||||
|  | +#define CRC32_BE_POLY_DEFAULT		0x04c11db7 | ||||||
|  | +#define CRC32_TABLE_ITEMS		256 | ||||||
|  | + | ||||||
|  | +static uint32_t crc32_le_calc(uint32_t crc, const uint8_t *data, size_t length, | ||||||
|  | +			      const uint32_t *crc_table) | ||||||
|  | +{ | ||||||
|  | +	while (length--) | ||||||
|  | +		crc = crc_table[(uint8_t)(crc ^ *data++)] ^ (crc >> 8); | ||||||
|  | + | ||||||
|  | +	return crc; | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +static void crc32_le_init(uint32_t *crc_table, uint32_t poly) | ||||||
|  | +{ | ||||||
|  | +	uint32_t i, j, v; | ||||||
|  | + | ||||||
|  | +	for (i = 0; i < CRC32_TABLE_ITEMS; i++) { | ||||||
|  | +		v = i; | ||||||
|  | + | ||||||
|  | +		for (j = 0; j < 8; j++) | ||||||
|  | +			v = (v >> 1) ^ ((v & 1) ? poly : 0); | ||||||
|  | + | ||||||
|  | +		crc_table[i] = v; | ||||||
|  | +	} | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +static uint32_t crc32_be_calc(uint32_t crc, const uint8_t *data, size_t length, | ||||||
|  | +			      const uint32_t *crc_table) | ||||||
|  | +{ | ||||||
|  | +	while (length--) | ||||||
|  | +		crc = crc_table[(uint8_t)((crc >> 24) ^ *data++)] ^ (crc << 8); | ||||||
|  | + | ||||||
|  | +	return crc; | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +static void crc32_be_init(uint32_t *crc_table, uint32_t poly) | ||||||
|  | +{ | ||||||
|  | +	uint32_t i, j, v; | ||||||
|  | + | ||||||
|  | +	for (i = 0; i < CRC32_TABLE_ITEMS; i++) { | ||||||
|  | +		v = i << 24; | ||||||
|  | + | ||||||
|  | +		for (j = 0; j < 8; j++) | ||||||
|  | +			v = (v << 1) ^ ((v & (1 << 31)) ? poly : 0); | ||||||
|  | + | ||||||
|  | +		crc_table[i] = v; | ||||||
|  | +	} | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +struct crc_funcs { | ||||||
|  | +	uint32_t poly; | ||||||
|  | + | ||||||
|  | +	void (*init)(uint32_t *crc_table, uint32_t poly); | ||||||
|  | +	uint32_t (*calc)(uint32_t crc, const uint8_t *data, size_t length, | ||||||
|  | +			 const uint32_t *crc_table); | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +static const struct crc_funcs crc32_le = { | ||||||
|  | +	.poly = CRC32_LE_POLY_DEFAULT, | ||||||
|  | +	.init = crc32_le_init, | ||||||
|  | +	.calc = crc32_le_calc, | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +static const struct crc_funcs crc32_be = { | ||||||
|  | +	.poly = CRC32_BE_POLY_DEFAULT, | ||||||
|  | +	.init = crc32_be_init, | ||||||
|  | +	.calc = crc32_be_calc, | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +static const struct crc_funcs *crc32_algo = &crc32_le; | ||||||
|  | +static uint32_t crc32_poly; | ||||||
|  | +static uint32_t crc32_val; | ||||||
|  | +static const char *input_file; | ||||||
|  | +static bool output_decimal; | ||||||
|  | +static bool no_comp; | ||||||
|  | + | ||||||
|  | +static void err(const char *fmt, ...) | ||||||
|  | +{ | ||||||
|  | +	va_list ap; | ||||||
|  | + | ||||||
|  | +	va_start(ap, fmt); | ||||||
|  | +	fprintf(stderr, "Error: "); | ||||||
|  | +	vfprintf(stderr, fmt, ap); | ||||||
|  | +	va_end(ap); | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +static void usage(FILE *con, const char *progname, int exitcode) | ||||||
|  | +{ | ||||||
|  | +	const char *prog; | ||||||
|  | +	size_t len; | ||||||
|  | + | ||||||
|  | +	len = strlen(progname); | ||||||
|  | +	prog = progname + len - 1; | ||||||
|  | + | ||||||
|  | +	while (prog > progname) { | ||||||
|  | +		if (*prog == '\\' || *prog == '/') { | ||||||
|  | +			prog++; | ||||||
|  | +			break; | ||||||
|  | +		} | ||||||
|  | + | ||||||
|  | +		prog--; | ||||||
|  | +	} | ||||||
|  | + | ||||||
|  | +	fprintf(con, "CRC32 checksum tool\n"); | ||||||
|  | +	fprintf(con, "\n"); | ||||||
|  | +	fprintf(con, "Usage: %s [options] <input_file>\n", prog); | ||||||
|  | +	fprintf(con, "\n"); | ||||||
|  | +	fprintf(con, "Options:\n"); | ||||||
|  | +	fprintf(con, "\t-h         display help message\n"); | ||||||
|  | +	fprintf(con, "\t-i <val>   crc value for incremental calculation\n"); | ||||||
|  | +	fprintf(con, "\t           (default is 0)\n"); | ||||||
|  | +	fprintf(con, "\t-p <val>   polynomial for calculation\n"); | ||||||
|  | +	fprintf(con, "\t           (default is 0x%08x for LE, 0x%08x for BE)\n", | ||||||
|  | +		crc32_le.poly, crc32_be.poly); | ||||||
|  | +	fprintf(con, "\t-b         use big-endian mode\n"); | ||||||
|  | +	fprintf(con, "\t-n         do not use one's complement\n"); | ||||||
|  | +	fprintf(con, "\t-d         use decimal output\n"); | ||||||
|  | +	fprintf(con, "\n"); | ||||||
|  | + | ||||||
|  | +	exit(exitcode); | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +static int parse_args(int argc, char *argv[]) | ||||||
|  | +{ | ||||||
|  | +	int opt; | ||||||
|  | + | ||||||
|  | +	static const char *optstring = "i:p:bndh"; | ||||||
|  | + | ||||||
|  | +	opterr = 0; | ||||||
|  | + | ||||||
|  | +	while ((opt = getopt(argc, argv, optstring)) >= 0) { | ||||||
|  | +		switch (opt) { | ||||||
|  | +		case 'i': | ||||||
|  | +			if (!isxdigit(optarg[0])) { | ||||||
|  | +				err("Invalid crc value - %s\n", optarg); | ||||||
|  | +				return -EINVAL; | ||||||
|  | +			} | ||||||
|  | + | ||||||
|  | +			crc32_val = strtoul(optarg, NULL, 0); | ||||||
|  | +			break; | ||||||
|  | + | ||||||
|  | +		case 'p': | ||||||
|  | +			if (!isxdigit(optarg[0])) { | ||||||
|  | +				err("Invalid polynomial value - %s\n", optarg); | ||||||
|  | +				return -EINVAL; | ||||||
|  | +			} | ||||||
|  | + | ||||||
|  | +			crc32_poly = strtoul(optarg, NULL, 0); | ||||||
|  | +			break; | ||||||
|  | + | ||||||
|  | +		case 'b': | ||||||
|  | +			crc32_algo = &crc32_be; | ||||||
|  | +			break; | ||||||
|  | + | ||||||
|  | +		case 'n': | ||||||
|  | +			no_comp = true; | ||||||
|  | +			break; | ||||||
|  | + | ||||||
|  | +		case 'd': | ||||||
|  | +			output_decimal = true; | ||||||
|  | +			break; | ||||||
|  | + | ||||||
|  | +		case 'h': | ||||||
|  | +			usage(stdout, argv[0], 0); | ||||||
|  | +			break; | ||||||
|  | + | ||||||
|  | +		default: | ||||||
|  | +			usage(stderr, argv[0], EXIT_FAILURE); | ||||||
|  | +		} | ||||||
|  | +	} | ||||||
|  | + | ||||||
|  | +	if (!crc32_poly) | ||||||
|  | +		crc32_poly = crc32_algo->poly; | ||||||
|  | + | ||||||
|  | +	if (optind >= argc) | ||||||
|  | +		input_file = "-"; | ||||||
|  | +	else | ||||||
|  | +		input_file = argv[optind]; | ||||||
|  | + | ||||||
|  | +	if (!input_file[0]) { | ||||||
|  | +		err("Input file must not be empty\n"); | ||||||
|  | +		return -EINVAL; | ||||||
|  | +	} | ||||||
|  | + | ||||||
|  | +	return 0; | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +static int crc32_calc(void) | ||||||
|  | +{ | ||||||
|  | +	uint32_t crc_table[CRC32_TABLE_ITEMS]; | ||||||
|  | +	bool using_stdin = false; | ||||||
|  | +	uint8_t buf[4096]; | ||||||
|  | +	size_t size; | ||||||
|  | +	int ret, i; | ||||||
|  | +	FILE *f; | ||||||
|  | + | ||||||
|  | +	if (!strcmp(input_file, "-")) { | ||||||
|  | +		SET_BINARY_MODE(stdin); | ||||||
|  | +		using_stdin = true; | ||||||
|  | +		f = stdin; | ||||||
|  | +	} else { | ||||||
|  | +		f = fopen(input_file, "rb"); | ||||||
|  | +	} | ||||||
|  | + | ||||||
|  | +	if (!f) { | ||||||
|  | +		err("Failed to open file '%s'\n", input_file); | ||||||
|  | +		return -EINVAL; | ||||||
|  | +	} | ||||||
|  | + | ||||||
|  | +	crc32_algo->init(crc_table, crc32_poly); | ||||||
|  | + | ||||||
|  | +	if (!no_comp) | ||||||
|  | +		crc32_val ^= 0xffffffff; | ||||||
|  | + | ||||||
|  | +	do { | ||||||
|  | +		size = fread(buf, 1, sizeof(buf), f); | ||||||
|  | + | ||||||
|  | +		if (size) { | ||||||
|  | +			crc32_val = crc32_algo->calc(crc32_val, buf, size, | ||||||
|  | +						     crc_table); | ||||||
|  | +		} | ||||||
|  | + | ||||||
|  | +		if (size < sizeof(buf)) { | ||||||
|  | +			ret = ferror(f); | ||||||
|  | + | ||||||
|  | +			if (!ret && feof(f)) | ||||||
|  | +				break; | ||||||
|  | + | ||||||
|  | +			err("Error while reading file: %d\n", ret); | ||||||
|  | +			break; | ||||||
|  | +		} | ||||||
|  | +	} while (true); | ||||||
|  | + | ||||||
|  | +	if (!using_stdin) | ||||||
|  | +		fclose(f); | ||||||
|  | + | ||||||
|  | +	if (ret) | ||||||
|  | +		return ret; | ||||||
|  | + | ||||||
|  | +	if (!no_comp) | ||||||
|  | +		crc32_val ^= 0xffffffff; | ||||||
|  | + | ||||||
|  | +	if (output_decimal) | ||||||
|  | +		printf("%u\n", crc32_val); | ||||||
|  | +	else | ||||||
|  | +		printf("%08x\n", crc32_val); | ||||||
|  | + | ||||||
|  | +	return 0; | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +int main(int argc, char *argv[]) | ||||||
|  | +{ | ||||||
|  | +	if (parse_args(argc, argv)) | ||||||
|  | +		return 1; | ||||||
|  | + | ||||||
|  | +	return crc32_calc(); | ||||||
|  | +} | ||||||
|  | --  | ||||||
|  | 2.43.2 | ||||||
|  |  | ||||||
							
								
								
									
										19
									
								
								profiles/sonicfi_rap630w-211g.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								profiles/sonicfi_rap630w-211g.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | --- | ||||||
|  | profile: sonicfi_rap630w_211g | ||||||
|  | target: mediatek | ||||||
|  | subtarget: mt7981 | ||||||
|  | description: Build image for the Mediatek MT7981 | ||||||
|  | image: bin/targets/mediatek/mt7981/openwrt-mediatek-mt7981-sonicfi_rap630w_211g-squashfs-sysupgrade.tar | ||||||
|  | feeds: | ||||||
|  |   - name: mediatek | ||||||
|  |     path: ../../feeds/mediatek-sdk | ||||||
|  | include: | ||||||
|  |   - ucentral-ap | ||||||
|  | packages: | ||||||
|  |   - mediatek | ||||||
|  | diffconfig: | | ||||||
|  |   # CONFIG_PACKAGE_kmod-nft-offload is not set | ||||||
|  |   # CONFIG_PACKAGE_procd-ujail is not set | ||||||
|  |   # CONFIG_PACKAGE_kmod-usb3 is not set | ||||||
|  |   # CONFIG_PACKAGE_mt7981-wo-firmware is not set | ||||||
|  |   CONFIG_PACKAGE_uboot-envtools=y | ||||||
		Reference in New Issue
	
	Block a user