rbextract: support devices with plain RLE caldata
Old MikroTik devices have the RLE-encoded radio calibration data directly stored in the art (hard_config) partition, without LZO compression nor any preceding ERD magic bytes. This commit adds a fallback for these devices. Tested on the ath79 target with a MikroTik SXT 5nD r2 (SXT Lite5), only locally --not yet merged upstream--. Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
This commit is contained in:
		 Roger Pueyo Centelles
					Roger Pueyo Centelles
				
			
				
					committed by
					
						 Koen Vandeputte
						Koen Vandeputte
					
				
			
			
				
	
			
			
			 Koen Vandeputte
						Koen Vandeputte
					
				
			
						parent
						
							3660a89cb9
						
					
				
				
					commit
					c81b2e94c7
				
			| @@ -11,7 +11,7 @@ | |||||||
| include $(TOPDIR)/rules.mk | include $(TOPDIR)/rules.mk | ||||||
|  |  | ||||||
| PKG_NAME:=rbextract | PKG_NAME:=rbextract | ||||||
| PKG_RELEASE:=2 | PKG_RELEASE:=3 | ||||||
| CMAKE_INSTALL:=1 | CMAKE_INSTALL:=1 | ||||||
|  |  | ||||||
| include $(INCLUDE_DIR)/package.mk | include $(INCLUDE_DIR)/package.mk | ||||||
|   | |||||||
| @@ -335,7 +335,7 @@ __rb_get_wlan_data(void) | |||||||
| 	} | 	} | ||||||
| 	/* Older ath79-based boards directly show the RB_MAGIC_ERD bytes followed by | 	/* Older ath79-based boards directly show the RB_MAGIC_ERD bytes followed by | ||||||
| 	the LZO-compressed calibration data with no RLE */ | 	the LZO-compressed calibration data with no RLE */ | ||||||
| 	if (magic == RB_MAGIC_ERD) { | 	else if (magic == RB_MAGIC_ERD) { | ||||||
| 		if (tag_len > RB_ART_SIZE) { | 		if (tag_len > RB_ART_SIZE) { | ||||||
| 			printf("Calibration data too large\n"); | 			printf("Calibration data too large\n"); | ||||||
| 			goto err_free_lzo_in; | 			goto err_free_lzo_in; | ||||||
| @@ -362,6 +362,18 @@ __rb_get_wlan_data(void) | |||||||
|  |  | ||||||
| 		buf_rle_out = buf_lzo_out; | 		buf_rle_out = buf_lzo_out; | ||||||
| 	} | 	} | ||||||
|  | 	/* Even older ath79-base boards directly have RLE-encoded calibration data, | ||||||
|  | 	without any LZO compresion nor showing RB_MAGIC_ERD bytes */ | ||||||
|  | 	else { | ||||||
|  | 		printf("Decode calibration data with RLE\n"); | ||||||
|  | 		err = rle_decode(tag, tag_len, buf_rle_out, RB_ART_SIZE, | ||||||
|  | 				 NULL, NULL); | ||||||
|  | 		if (err) { | ||||||
|  | 			printf("unable to decode ERD data\n"); | ||||||
|  | 			goto err_free_rle_out; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return buf_rle_out; | 	return buf_rle_out; | ||||||
|  |  | ||||||
| err_free_rle_out: | err_free_rle_out: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user