Rebuild firmware with a modified patch

Hi, I have recently built firmware for my Turris Omnia with a patch supplied by compex for their wle1216vx dual band m-pcie module, the firmware built without errors but the band switching didn't quite function correctly. I received a new patch yesterday and would like to rebuild the same firmware but with the new patch. I've been reading and searching for an answer to my question but due to my lack of knowledge I'm still unsure of how to do this without starting from scratch.
Question: I would like to keep the menuconfig that I setup on the first build and then build a new version with the updated patch applied. What is the correct way to do this, should I start from scratch with make clean first or can I just substitute the newer patch and issue make again, should I update feeds too.
Apologies if this has been answered before.

It really depends on what the patch is. Does it patch a package, is it a separate package? What does it patch?

Can you give us some more info?

Yes of course, this is the patch

$ cat patches/990-ath10k-ct--dualband-bmi-param-support.patch 
--- a/ath10k-4.19/bmi.h
+++ b/ath10k-4.19/bmi.h
@@ -86,6 +86,10 @@ enum bmi_cmd_id {
 #define BMI_PARAM_GET_FLASH_BOARD_ID 0x8000
 #define BMI_PARAM_FLASH_SECTION_ALL 0x10000
 
+/* Dual-band Param IDs */
+#define BMI_PARAM_DUAL_BAND_2G 0x40000
+#define BMI_PARAM_DUAL_BAND_5G 0x80000
+
 #define ATH10K_BMI_BOARD_ID_FROM_OTP_MASK   0x7c00
 #define ATH10K_BMI_BOARD_ID_FROM_OTP_LSB    10
 
--- a/ath10k-4.19/core.c
+++ b/ath10k-4.19/core.c
@@ -41,6 +41,8 @@
 unsigned int ath10k_debug_mask = ATH10K_DBG_NO_DBGLOG;
 
 static unsigned int ath10k_cryptmode_param;
+static unsigned int ath10k_dual_band_config;
+static unsigned int ath10k_dual_band_idx[4] = {0, 0, 0, 0};
 static bool uart_print;
 static bool skip_otp;
 static bool rawmode;
@@ -56,6 +58,7 @@ MODULE_PARM_DESC(override_eeprom_regdoma
 
 module_param_named(debug_mask, ath10k_debug_mask, uint, 0644);
 module_param_named(cryptmode, ath10k_cryptmode_param, uint, 0644);
+module_param_named(dual_band, ath10k_dual_band_config, uint, 0644);
 module_param(uart_print, bool, 0644);
 module_param(skip_otp, bool, 0644);
 module_param(rawmode, bool, 0644);
@@ -65,6 +68,7 @@ MODULE_PARM_DESC(debug_mask, "Debugging
 MODULE_PARM_DESC(uart_print, "Uart target debugging");
 MODULE_PARM_DESC(skip_otp, "Skip otp failure for calibration in testmode");
 MODULE_PARM_DESC(cryptmode, "Crypto mode: 0-hardware, 1-software");
+MODULE_PARM_DESC(dual_band, "Ath10k dual-band config: 2 - 2.4Ghz, 5 - 5Ghz");
 MODULE_PARM_DESC(rawmode, "Use raw 802.11 frame datapath");
 MODULE_PARM_DESC(coredump_mask, "Bitfield of what to include in firmware crash file");
 
@@ -999,6 +1003,28 @@ static int ath10k_core_get_board_id_from
 	else
 		bmi_board_id_param = BMI_PARAM_GET_EEPROM_BOARD_ID;
 
+	/* Select radio band from user module-param 'dual_band' */
+	{
+		int wiphy_idx;
+		for ( wiphy_idx = 0; wiphy_idx < 4; wiphy_idx++ ) {
+			if ( ath10k_dual_band_idx[wiphy_idx] == (unsigned int)ar )
+				break;
+			if ( ath10k_dual_band_idx[wiphy_idx] == 0 ) {
+				ath10k_dual_band_idx[wiphy_idx] = (unsigned int)ar;
+				break;
+			}
+		}
+		if ((ath10k_dual_band_config >> (wiphy_idx * 8) & 0xff) == 2) {
+			bmi_board_id_param |= BMI_PARAM_DUAL_BAND_2G;
+			ath10k_dbg(ar, ATH10K_DBG_BOOT,
+					"Dual-band configuring with 2.4Ghz");
+		} else if ((ath10k_dual_band_config >> (wiphy_idx * 8) & 0xff) == 5) {
+			bmi_board_id_param |= BMI_PARAM_DUAL_BAND_5G;
+			ath10k_dbg(ar, ATH10K_DBG_BOOT,
+					"Dual-band configuring with 5Ghz");
+		}
+	}
+
 	ret = ath10k_bmi_execute(ar, address, bmi_board_id_param, &result);
 	if (ret) {
 		ath10k_err(ar, "could not execute otp for board id check: %d\n",
@@ -1155,6 +1181,28 @@ static int ath10k_download_and_run_otp(s
 	    ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE)
 		bmi_otp_exe_param = BMI_PARAM_FLASH_SECTION_ALL;
 
+	/* Select radio band from user module-param 'dual_band' */
+	{
+		int wiphy_idx;
+		for ( wiphy_idx = 0; wiphy_idx < 4; wiphy_idx++ ) {
+			if ( ath10k_dual_band_idx[wiphy_idx] == (unsigned int)ar )
+				break;
+			if ( ath10k_dual_band_idx[wiphy_idx] == 0 ) {
+				ath10k_dual_band_idx[wiphy_idx] = (unsigned int)ar;
+				break;
+			}
+		}
+		if ((ath10k_dual_band_config >> (wiphy_idx * 8) & 0xff) == 2) {
+			bmi_otp_exe_param |= BMI_PARAM_DUAL_BAND_2G;
+			ath10k_dbg(ar, ATH10K_DBG_BOOT,
+					"Dual-band OTP with 2.4Ghz");
+		} else if ((ath10k_dual_band_config >> (wiphy_idx * 8) & 0xff) == 2) {
+			bmi_otp_exe_param |= BMI_PARAM_DUAL_BAND_5G;
+			ath10k_dbg(ar, ATH10K_DBG_BOOT,
+					"Dual-band OTP with 5Ghz");
+		}
+	}
+
 	ret = ath10k_bmi_execute(ar, address, bmi_otp_exe_param, &result);
 	if (ret) {
 		ath10k_err(ar, "could not execute otp (%d)\n", ret);

And the instructions tell me to copy it to here

$BUILDROOT/package/kernel/ath10k-ct/patches/

It patches the ath10k-ct kernel module to support the wle1216vx compex card and I guess its also modifying the kernel?
Edit: link to firmware https://www.dropbox.com/s/jyhki6kodcz6d9n/wle1216vx-ath10k-ct-support.zip?dl=0

That's a kernel patch. Given that it applies cleanly, you don't need to rebuild everything.

I'd recommend copying it to the folder and then

make target/linux/clean V=s
make -j9 V=s

This will force a kernel and module rebuild without rebuilding all your packages. If it fails, reinvoke with a -j1 flag as sometimes the parallel builds fail.

2 Likes

That worked, thank you!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.