You are not logged in.

#1 2019-10-17 13:36:32

navi_se
Member
Registered: 2015-07-06
Posts: 135

Help converting my RPM bios flashing utility to a PKGBUILD

I have a Z230 HP workstation and I'm trying to install the latest BIOS. HP provides a rpm installer for it .

It comes as a one-two punch: the 'xwbios' kernel module as a source rpm named hp-lxbios-mod.<version>.src.rpm and the 'lxbios' application rpm hp-lxbios.<version>.rpm that does the actual updating.

I've prodded a bit and I think there won't be an easy solution (like running rpm itself or some half-assed way to build a PKGBUILD) and I probably need to go deep and unpack the rpm and turn it into a proper PKGBUILD, but I'm a bit out of my depth: I would really like to avoid bricking the machine (there's a failsafe boot recovery mode if I fuck this up, but still..) and I've built some very simple PKGBUILD before, but it looks like this needs some compiling on my side as well as locating stuff I don't really know about, so I humbly need some help.

I will start with the kernel module.

As far as I understand, within the kernel module .rpm I found a .spec file which looks like the rpm equivalent of a PKGBUILD, here it is:

# HP .spec for lxbios kernel module rpm

## 
# Hewlett-Packard Company Confidential (C) Copyright 2008 Hewlett-Packard Development Company, L.P.
# All rights reserved.
#
# Disclaimer of Warranty: This software is experimental and
# provided "as-is" by Hewlett-Packard Development Company,
# LP. ("HP")  HP shall have no obligation to maintain or
# support this software.  HP makes no express or implied
# warranty of any kind regarding this software including any
# warranties of merchantability, fitness for a particular
# purpose, title or non-infringement.  HP shall not be liable
# for any direct, indirect, special, incidental, or consequential
# damages, whether based on contract, tort or any other legal
# theory, in connection with or arising out of the furnishing,
# performance or use of this software.
## 
## kernel version
# if kversion isn't defined on rpm build line, build against current kernel
#%{!?kversion: %define kversion %(uname -r)}

%define kversion %(uname -r)

# hint: this can he overridden with "--define kversion foo" on the rpmbuild command line, e.g.
# --define "kversion 2.6.16-1.2096_FC5"

## Kernel Variants
# This spec only meant for currently running kernel. 

%define logFile /var/log/hp-lxbios.log
%define targetDir /lib/modules/%{kversion}/kernel/drivers/xwkernel


Name:       hp-lxbios-mod
Version:    3.1
Release:    1_%(echo %{kversion} | tr - .)
Summary:    hp lxbios BIOS flash utility kernel module

License:    Redistributable, no modification permitted
Group:      System Environment/Kernel
#URL:        http://www.

## Source is created from these files: 
Source0:     %{name}.tgz

ExclusiveOS: linux
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
#ExclusiveArch: i386 x86_64

%description
The hp lxbios %{version} kernel module for kernel %{kversion}.


%prep
%setup -q -c -a 0


%build
[ -n $RPM_BUILD_ROOT -a "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}
cd hp-lxbios-mod
# make
./mkit


%install
rm -rf $RPM_BUILD_ROOT
install -D -m 0644 hp-lxbios-mod/xwbios.ko $RPM_BUILD_ROOT/%{targetDir}/xwbios.ko
chmod u+x $RPM_BUILD_ROOT/%{targetDir}/xwbios.ko


%clean
[ -n $RPM_BUILD_ROOT -a "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT


%post
# Register the module
depmod
modprobe xwbios


%postun
depmod


%files
%{targetDir}/xwbios.ko

%changelog
* Wed Jul 28 2010 Lance Celli <lance.celli@hp.com>
- preun- section removed because that functionality
- is handled by the script which launches lxbios.

* Tue Jun 22 2010 Lance Celli <lance.celli@hp.com>
- targetDir changed and a bit cleanup
- post-, preun- and postun-sections added

* Mon Jun 12 2008 Ian Erickson <ian.erickson@hp.com>
- Initial package creation.  

hp-lxbios-mod.tgz file that I can extract and has the following structures, which contains all that is needed to build:

hp-lxbios-mod/mymod.c
hp-lxbios-mod/mymod.mod.c
hp-lxbios-mod/xwbios.c
hp-lxbios-mod/xwbios.mod.c
hp-lxbios-mod/xwbios.h
hp-lxbios-mod/Makefile
hp-lxbios-mod/mkit

where mkit is a script dedicated to doing some kernel related stuff which might need some translation

#!/bin/bash

if [ -d /lib/modules/`uname -r`/build ]; then
    ksrc=/lib/modules/`uname -r`/build
elif [ -d /lib/modules/`uname -r`/source ]; then
    ksrc=/lib/modules/`uname -r`/source
else
    echo "*** mkit: Error - unable to define kernel source location"
    exit -1
fi
echo "Kernel source dir is $ksrc"
# Setup kernel build of xwkernel module
rm -f $ksrc/xwkernel
ln -s /opt/hp/hp-lxbios/xwkernel $ksrc/xwkernel 
make -C $ksrc M=$PWD modules 

.

So, my first question here is: mkit is looking for a source or build folder under my

/lib/modules/<kernel>/

which currently doesn't exist so mkit fails, should I just make one? Or is there another `source` folder I should point this to, under arch?

Offline

#2 2019-10-17 14:10:47

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: Help converting my RPM bios flashing utility to a PKGBUILD

The kernel source folders are provided by the linux-headers package for your specific kernel.

Offline

#3 2019-10-17 15:58:33

navi_se
Member
Registered: 2015-07-06
Posts: 135

Re: Help converting my RPM bios flashing utility to a PKGBUILD

Hey thanks, I've managed (and learned a bit about compiling kernel modules), so I have linux_headers installed.

I believe the

\.mkit

script will call make and build the module directly in my <kernel-version>/build/ folder, but if I run it I get an obscure error from gcc, I was expecting for the compilation to go through here, but maybe I'm missing an option somewhere?

Kernel source dir is /lib/modules/5.3.6-arch1-1-ARCH/build
make: Entering directory '/usr/lib/modules/5.3.6-arch1-1-ARCH/build'
  CC [M]  /home/gls/Downloads/bios_iupdate/lxbios/hp-lxbios-mod/xwbios.o
/home/gls/Downloads/bios_iupdate/lxbios/hp-lxbios-mod/xwbios.c:125:23: error: initialization of ‘long int (*)(struct file *, unsigned int,  long unsigned int ’ from incompatible pointer type ‘int (*)(struct inode *, struct file *, unsigned int,  long unsigned int)’ [-Werror=incompatible-pointer-types]
  125 |     .unlocked_ioctl = xwbios_ioctl,
      |                       ^~~~~~~~~~~~
/home/gls/Downloads/bios_iupdate/lxbios/hp-lxbios-mod/xwbios.c:125:23: note: (near initialization for ‘xwbios_fops.unlocked_ioctl’)
/home/gls/Downloads/bios_iupdate/lxbios/hp-lxbios-mod/xwbios.c: In function ‘xwbios_exit’:
/home/gls/Downloads/bios_iupdate/lxbios/hp-lxbios-mod/xwbios.c:666:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  666 |     if (pReqPwdBuffer)
      |     ^~
/home/gls/Downloads/bios_iupdate/lxbios/hp-lxbios-mod/xwbios.c:668:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  668 |  if (pRepsetGetInfo != NULL)
      |  ^~
cc1: some warnings being treated as errors
make[1]: *** [scripts/Makefile.build:281: /home/gls/Downloads/bios_iupdate/lxbios/hp-lxbios-mod/xwbios.o] Error 1
make: *** [Makefile:1626: _module_/home/gls/Downloads/bios_iupdate/lxbios/hp-lxbios-mod] Error 2
make: Leaving directory '/usr/lib/modules/5.3.6-arch1-1-ARCH/build'

the Makefile I have only says

#obj-m := mymod.o
obj-m := xwbios.o

clean:
	rm -f *.o *.ko

install:
	mkdir -p /opt/hp/hp-lxbios/xwkernel
	cp xwbios.ko /opt/hp/hp-lxbios/xwkernel/

Last edited by navi_se (2019-10-17 15:59:03)

Offline

#4 2019-10-17 16:27:01

loqs
Member
Registered: 2014-03-06
Posts: 17,193

Re: Help converting my RPM bios flashing utility to a PKGBUILD

Please provide a link to the source archives you are examining.

Online

#5 2019-10-17 16:44:28

navi_se
Member
Registered: 2015-07-06
Posts: 135

Re: Help converting my RPM bios flashing utility to a PKGBUILD

Eh, I thought I did, but I was wrong, here they are:

https://support.hp.com/gb-en/drivers/se … on/5367825

you can download sp97093.tgz under the BIOS tab on that page. After unpacking, under the lxbios folder you'll find the two rpms and the readme file describing rpm install procedure.

EDIT: assuming this is what you wanted, if you want to know about the kernel source I just got it by installing linux-headers

Last edited by navi_se (2019-10-17 16:45:27)

Offline

#6 2019-10-17 16:54:08

loqs
Member
Registered: 2014-03-06
Posts: 17,193

Re: Help converting my RPM bios flashing utility to a PKGBUILD

The newest kernel it appears to support is 2.6.10 which is nearly 15 years old.
Edit:
Have you tried fwupd before attempting to build this package?

Last edited by loqs (2019-10-17 17:00:15)

Online

#7 2019-10-17 16:57:10

navi_se
Member
Registered: 2015-07-06
Posts: 135

Re: Help converting my RPM bios flashing utility to a PKGBUILD

I was going by the release date which was June 2019, so I assumed this would be appropriate. I guess I will have to try boot into a DOS live usb and flash it from there?

Last edited by navi_se (2019-10-17 17:04:08)

Offline

#8 2019-10-17 23:33:17

loqs
Member
Registered: 2014-03-06
Posts: 17,193

Re: Help converting my RPM bios flashing utility to a PKGBUILD

My order of preference would be fwupd , dos , fix the kernel module.
The following patch allowed the module to build under linux 5.3

diff --git a/xwbios.c b/xwbios.c
index 23e6584..c994299 100644
--- a/xwbios.c
+++ b/xwbios.c
@@ -97,7 +97,7 @@ MODULE_PARM_DESC(xwbios_major, "Major device number");
 // Module function declarations
 //static ssize_t xwbios_read( struct file *file, char __user *buf,
 //size_t len, loff_t *ppos );
-static int xwbios_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg);
+static long int xwbios_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
 
 static ssize_t xwbios_write( struct file *file, const char __user *data,
 			     size_t len, loff_t *ppos );
@@ -196,8 +196,7 @@ static int xwbios_release(struct inode *inode, struct file *file)
 }
 
 #if defined(KERNEL_64bit)
-static int xwbios_ioctl( struct inode *ip, struct file *fp,
-			 unsigned cmd, unsigned long arg)
+static long int xwbios_ioctl( struct file *fp, unsigned cmd, unsigned long arg)
 {
 	xwprintk((KERN_INFO "xwbios: xwbios_ioctl called \n"));
 	return 0;
@@ -653,23 +652,23 @@ static int __init xwbios_init(void)
 static void __exit xwbios_exit(void)
 {
 
-    if (pRomHeader != NULL)
+	if (pRomHeader != NULL)
 		kfree(pRomHeader);
 	if (pRomImageBuffer != NULL)
 		kfree(pRomImageBuffer);
 	if (pRepsetRequest != NULL)
 		kfree(pRepsetRequest);
-    if (pRepsetEfiOp)
-        kfree(pRepsetEfiOp);
-    if (pReqBuffer)
-        kfree(pReqBuffer);
-    if (pReqPwdBuffer)
-        kfree(pReqPwdBuffer);
+	if (pRepsetEfiOp)
+		kfree(pRepsetEfiOp);
+	if (pReqBuffer)
+		kfree(pReqBuffer);
+	if (pReqPwdBuffer)
+		kfree(pReqPwdBuffer);
 	if (pRepsetGetInfo != NULL)
 		kfree(pRepsetGetInfo);
 	if (pValueBuffer != NULL)
 		kfree(pValueBuffer);
-    
+
 	unregister_chrdev(xwbios_major, MODULE_NAME);
     //misc_deregister(&xwbios_device);
 #if defined(KERNEL_64bit)

Online

#9 2019-10-25 19:13:05

paulkerry
Member
From: Sheffield, UK
Registered: 2014-10-02
Posts: 611

Re: Help converting my RPM bios flashing utility to a PKGBUILD

Coming late to this topic, does your HP Z230 allow updating the BIOS using local media (i.e. usb) from BIOS itself?

I've done BIOS upgrades on several HP machines, including Z series but not the Z230, usually by copying the xnn_nnnn.bin file extracted from the HP download to usb stick and then pressing "Esc" at boot and using BIOS to "update using local media" or "bios update".

For some models...
- you sometimes have to copy extra files to the usb stick and/or put files like the .bin file, into particular (sub)directories, like {usb_root}/Hewlett-Packard/BIOS/New
- you sometimes have to download the BIOS file from the HP site as a Windows .exe file, on which you can use "file-roller spnnnn.exe" to extract the files to get to the .bin file
- you sometimes have to enable usb booting for the bios files to be seen
- you sometimes cannot use a bootable usb stick, just use a vfat formatted stick

Cheers
Paul.

Last edited by paulkerry (2019-10-25 19:14:10)

Offline

#10 2019-10-25 23:42:41

cfeedback
Member
From: Portland, OR
Registered: 2019-05-11
Posts: 11

Re: Help converting my RPM bios flashing utility to a PKGBUILD

Save yourself all this hassle and grab a copy of intel's Flash Programming Tool (FPT). It's extremely reliable and easy to use. This has a C226 chipset so it looks like it has ME9. Best ways to flash are from the EFI shell or DOS, but you can use Windows in a pinch. You might need to put a jumper on a "Flash Descriptor Override" (FDO) 2 pin header that HP's quite frequently have. I took a look at the bios, it's just a regular Intel image, the file you want to flash is the *.BIN file in the dos folder of the HP package. It's a 16MB image so you probably have a dual flash system of some sort, but FPT takes care of all that without any interaction on your part.

"fpt.efi -rewrite -f my_bios_file.bin -verbose" and then
"fpt.efi -greset" after it's done.

Intel ME System Tools v9.1 r7 - (2018-09-01) For 8/9/X99/C220/C610-series systems which run ME v9.0 - v9.1

hpbios.png

Last edited by cfeedback (2019-10-26 09:17:35)


Design is a funny word. Some people think design means how it looks. But, of course, if you dig deeper, it’s how it really works. You have to grok what it is all about.

― S. Jobs

Offline

Board footer

Powered by FluxBB