Something I did in a commit broke my code. I have a git bisect that shows me the last good commit and the first bad one.
Continue readingCategory Archives: Linux
recvfrom system call in python
With a socket created, and a message sent, the next step in our networking journey is to receive data.
Continue readingUpdated MCTP send code
While the existing documentation is good, there are a couple things that have changed since it was originally written, and I had to make a couple minor adjustments to get it to work. Here’s the code to send a message. The receive part should work as originally published; what is important is the set of headers. I built and ran this on an AARCH64 platform running Fedora 38.
Continue readingsocket system call from python
While the Python socket API is mature, it does not yet support MCTP. I thought I would thus try to make a call from python into native code. The first step is to create a socket. Here is my code to do that.
Note that this is not the entire C code needed to make network call, just the very first step.I did include the code to read errno if the call fails.
#!/usr/bin/python3
from ctypes import *
libc = CDLL("/lib64/libc.so.6")
AF_MCTP = 45
SOCK_DGRAM = 2
rc = libc.socket (AF_MCTP, SOCK_DGRAM, 0)
#print("rc = %d " % rc)
get_errno_loc = libc.__errno_location
get_errno_loc.restype = POINTER(c_int)
errno = get_errno_loc()[0]
print("rc = %d errno = %d" % (rc, errno) )
print("OK")
Running this code on my machine shows success
# ./spdm.py
rc = 3 errno = 0
OK
Round Trip with MCTP over PCC
The future Ampere System-on-a-chip that is the basis for my work has a couple of processors that are for providing system wide services, not for end users to run things on directly. One of these is called the Management Processor, or Mpro. We have to talk to one of these services from the operating system using the Management Control Transport Protocol, or MCTP, over a Platform Communication Channel (PCC).
I just sent ran a user-land program that sends a message via a socket into the operating system, via PCC, to the MPro, and got a response back.
It took a while for it to sink in. And then I raised my hands in the air and proclaimed in my Best Dr. Frankenstein voice,
“It’s Alive!”
Building a Fedora Based Linux Kernel
We have a few different ways we build a Kernel for internal consumption. One is very minimal, to be used when space is at a premium. Another is very closely based on the Fedora configuration to be used as a replacement Kernel for a Fedora install. While we do provide our team with RPMs to install, development often requires building from source. I’ve done this (and forgotten steps) enough times to want to have a quick reference. The following should work on a recent Fedora install.
Continue readingError building Kernel ln: target ‘+/source’: No such file or directory
I have battled this problem a couple times and so I am documenting the issue and solution here.
Here is the error message from make modules_install
ln: target '+/source': No such file or directory
Continue reading Finding a line of code in the Kernel from a stack trace
To find out what line a particular stack trace entry points to, use the script ./scripts/faddr2line for example If I have the line __get_vm_area_node+0x17c/0x1a8 I can run
./scripts/faddr2line vmlinux.o __get_vm_area_node+0x17c/0x1a8
__get_vm_area_node+0x17c/0x1a8:
__get_vm_area_node at /root/linux/mm/vmalloc.c:2579 (discriminator 1)
Following a code path in the Linux Kernel without a debugger
Sometimes you don’t get to use a debugger. When do bare metal development, often it is faster to get to the root of a problem by throwing in trace statements, and seeing what path is taken through the code.
Continue readingBuilding a Kernel RPM with the Built-in Makefile target
Note that you need to have a .config file that will be included in the build. It will also use the Version as specified in your Makefile. Then run
make rpm-pkg
Which will use the RPM build infra set up for your user to put the rpm in $HOME/rpmbuild/
Edit: Note that a bunch of dependencies are needed to get the Kernel to build. If you run the above command and it fails out with a message that you are missing a dependency, you can use this pair of commands to get the yum-build dep tool installed, and use that to install the dependencies as listed by the generated kernel.spec file.
wget https://src.fedoraproject.org/rpms/kernel/raw/rawhide/f/kernel.spec
yum install dnf-utils
yum-builddep ./kernel.spec