mirror of
				git://git.openwrt.org/openwrt/openwrt.git
				synced 2025-11-04 06:54:27 -05:00 
			
		
		
		
	package: add fitblk util to release /dev/fit* devices
Add minimalistic tool to allow releasing /dev/fit* devices which is needed on sysupgrade when using the fitblk driver. The package is hidden in menuconfig, it should only be selected by adding it to the default package selection of boards using it. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
		
							parent
							
								
									8fc5457869
								
							
						
					
					
						commit
						ddcc8f9f4e
					
				
							
								
								
									
										41
									
								
								package/utils/fitblk/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								package/utils/fitblk/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					include $(TOPDIR)/rules.mk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PKG_NAME:=fitblk
 | 
				
			||||||
 | 
					PKG_RELEASE:=1
 | 
				
			||||||
 | 
					PKG_LICENSE:=GPL-2.0-only
 | 
				
			||||||
 | 
					PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PKG_FLAGS:=nonshared
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					include $(INCLUDE_DIR)/package.mk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					define Package/fitblk
 | 
				
			||||||
 | 
					  HIDDEN:=1
 | 
				
			||||||
 | 
					  SECTION:=base
 | 
				
			||||||
 | 
					  CATEGORY:=Base system
 | 
				
			||||||
 | 
					  TITLE:=fitblk firmware release tool
 | 
				
			||||||
 | 
					  DEPENDS:=@LINUX_6_1
 | 
				
			||||||
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					define Package/fitblk/description
 | 
				
			||||||
 | 
					Release uImage.FIT block devices using ioctl.
 | 
				
			||||||
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					define Build/Configure
 | 
				
			||||||
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					define Build/Compile
 | 
				
			||||||
 | 
						$(MAKE) -C $(PKG_BUILD_DIR) \
 | 
				
			||||||
 | 
							CC="$(TARGET_CC)" \
 | 
				
			||||||
 | 
							CFLAGS="$(TARGET_CFLAGS) -Wall -Werror" \
 | 
				
			||||||
 | 
							LDFLAGS="$(TARGET_LDFLAGS)"
 | 
				
			||||||
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					define Package/fitblk/install
 | 
				
			||||||
 | 
						$(INSTALL_DIR) $(1)/usr/sbin
 | 
				
			||||||
 | 
						$(INSTALL_BIN) $(PKG_BUILD_DIR)/fitblk $(1)/usr/sbin/
 | 
				
			||||||
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$(eval $(call BuildPackage,fitblk))
 | 
				
			||||||
							
								
								
									
										7
									
								
								package/utils/fitblk/src/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								package/utils/fitblk/src/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					all: fitblk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fitblk:
 | 
				
			||||||
 | 
						$(CC) $(CFLAGS) -o $@ fitblk.c $(LDFLAGS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					clean:
 | 
				
			||||||
 | 
						rm -f fitblk
 | 
				
			||||||
							
								
								
									
										45
									
								
								package/utils/fitblk/src/fitblk.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								package/utils/fitblk/src/fitblk.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
				
			|||||||
 | 
					// SPDX-License-Identifier: GPL-2.0-only
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include <fcntl.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include <sys/ioctl.h>
 | 
				
			||||||
 | 
					#include <linux/fitblk.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int fitblk_release(char *device)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int fd, ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fd = open(device, O_RDONLY);
 | 
				
			||||||
 | 
						if (fd == -1)
 | 
				
			||||||
 | 
							return errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = ioctl(fd, FITBLK_RELEASE, NULL);
 | 
				
			||||||
 | 
						close(fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (ret == -1)
 | 
				
			||||||
 | 
							return errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main(int argc, char *argp[])
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (argc != 2) {
 | 
				
			||||||
 | 
							fprintf(stderr, "Release uImage.FIT sub-image block device\n");
 | 
				
			||||||
 | 
							fprintf(stderr, "Syntax: %s /dev/fitXXX\n", argp[0]);
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = fitblk_release(argp[1]);
 | 
				
			||||||
 | 
						if (ret)
 | 
				
			||||||
 | 
							fprintf(stderr, "fitblk: error releasing %s: %s\n", argp[1],
 | 
				
			||||||
 | 
								strerror(ret));
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							fprintf(stderr, "fitblk: %s released\n", argp[1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user