Install grub on a disk drive by UUID - grub

There is a way to indicate to grub to install on a device MBR by UUID instead of using /dev/sdX ? I'm setting a external eSATA hard disk with NixOS, and obviusly, the hard disk not would be always the same /dev/sdX device ?
I see that I can config it with boot.loader.grub.device = "/dev/sdX", but could set it to something like "/dev/disk/by-uuid/...." ??

currently there is no support for what you want in nixos.
see the respective source code here:
https://github.com/NixOS/nixpkgs/blob/release-15.09/nixos/modules/system/boot/loader/grub/grub.nix
however, you should be able to use:
boot.loader.grub.device = "/dev/mydisk"
but you will need a udev-ruleset like this:
services.udev.extraRules = ''
#Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", MODE="666", SYMLINK+="ttyUSB-odroid-u3-1"
#Bus 003 Device 055: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE="666", SYMLINK+="ttyUSB-odroid-u3-2"
# Bus 003 Device 057: ID 054c:0268 Sony Corp. Batoh Device / PlayStation 3 Controller
ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0268", SUBSYSTEMS=="usb", ACTION=="add", MODE="0660", GROUP="users"
'';
but for your external harddrive of course. just by using the symlink feature.

Related

usb Mass Storage driver for am335x

i want to loard a usb drive storage module so i make when i load usb mass storage module the usb drive detect in /media or /dev/sda1
I have one customized bord using an am335x processor and this board has one USB port(for USB drive connector) and one micro USB port. and also have kernel source code and version is 4.4.16 now i follow the command to compile kernel source code
make distclean CROSS_COMPILE=arm-linux-gnueabihf-
make am335x_fujitel_defconfig CROSS_COMPILE=arm-linux-gnueabihf-
note= am335x_fujitel_defconfig is my edited defconfig file according to my bord and after that type
make menuconfig
The reason is I want to make module of USB storage driver so i can install module first to connect my usb drive to the device
so i follow this link https://processors.wiki.ti.com/index.php/Usbgeneralpage#Mass_Storage_Gadget as reference
and changes some driver configurations.
I found that when i uncheck
< > Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...)
MUSB Mode Selection (Dual Role mode) --->
my usb drive not work on my device so I make module 'm' for Inventra Highspeed Dual Role Controller and generate musb-hdrc.ko file
I load new zImage and /lib/module/4/4/16 to my board and found .ko file in /lib... directory
root#arm:~# ls /lib/modules/4.4.16/kernel/drivers/usb/musb/musb_hdrc.ko
Now run "modprobe musb-hdrc" command and write "musb_hdrc" vi /etc/modules-load.d/modules.conf
above command run successfully and not see any error
after that reboot, the board run "lsmod" command to the sure module is load or not
root#arm:~# lsmod
Module Size Used by Not tainted
bridge 87777 0
stp 2111 1 bridge
llc 5184 2 bridge,stp
usb_f_rndis 21887 2
usb_f_ecm 9211 2
u_ether 11816 2 usb_f_rndis,usb_f_ecm
libcomposite 42715 16 usb_f_rndis,usb_f_ecm
omap_sham 22202 0
omap_aes_driver 19511 0
omap_rng 4212 0
rng_core 7198 1 omap_rng
musb_hdrc 78777 0
musb_hdrc load is successful.BUT when I connect my USB drive to USB port my USB drive not mount in /media also not show me at /dev why ?? am I missing something ?? also i check Kconfig file
config USB_MUSB_HDRC
tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...)'
depends on (USB || USB_GADGET)
help
Say Y here if your system has a dual role high speed USB
controller based on the Mentor Graphics silicon IP. Then
configure options to match your silicon and the board
it's being used with, including the USB peripheral role,
or the USB host role, or both.
Texas Instruments families using this IP include DaVinci
(35x, 644x ...), OMAP 243x, OMAP 3, and TUSB 6010.
Analog Devices parts using this IP include Blackfin BF54x,
BF525 and BF527.
Allwinner SoCs using this IP include A10, A13, A20, ...
If you do not know what this is, please say N.
To compile this driver as a module, choose M here; the
module will be called "musb-hdrc".
So after exploring many things, I found that when I mark 'm' in Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...) there are two another support which automatically goes to < > like
<M> Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...)
MUSB Mode Selection (Dual Role mode) --->
*** Platform Glue Layer ***
< > OMAP2430 and onwards
< > AM35x
< > TI DSPS platforms
*** MUSB DMA mode ***
[ ] Disable DMA (always use PIO)
Here I forgot to notice that TI DSPS platforms and Disable DMA also goes to empty(< >) automatically when I select Inventra Highspeed Dual Role Controller. so I also check TI DSPS platforms and <*> for Disable DMA and then cross compile kernel and modules again
Now after when my board boot up successfully I see 3 new modules
root#arm:~# ls /lib/modules/4.4.16/kernel/drivers/usb/musb/musb_
musb_am335x.ko musb_dsps.ko musb_hdrc.ko
Then type lsmod command
root#arm:~# lsmod
Module Size Used by Not tainted
bridge 87777 0
stp 2111 1 bridge
llc 5184 2 bridge,stp
usb_f_rndis 21887 2
usb_f_ecm 9211 2
u_ether 11816 2 usb_f_rndis,usb_f_ecm
libcomposite 42715 16 usb_f_rndis,usb_f_ecm
musb_dsps 9418 0
musb_hdrc 72752 1 musb_dsps
omap_aes_driver 19511 0
omap_sham 22202 0
omap_rng 4212 0
rng_core 7198 1 omap_rng
musb_am335x 1547 0 [permanent]
and I successfully connect my USB drive to device which detect in /media location
But I am surprised here how to Musb_* module load automatically? I can't understand also when i remove am335x from /lib directory, all musb* module remove automatically
So how do I solve this automatically load module issue? anyone help me

how add INF printer file on RPI3B+ (NTarm) windows iot core

I user RPI3B+ (OS: Windows iot core 10 v10.0.17661.1001) and I want to add a USB Kiosk Printer (Brand: SNBC)
I changed the OS in .inf file to use NTarm according described in this link
and then add .inf file with devcon add command, oem0.inf generate successfully and name of printer shows in connected devices after restart.
but I don't know how to test Printer to know that is enable and working or it is just a USB empty name
I tried application "CustomUsbDeviceAccess" from "Windows-universal-samples-master" . but it shows not device connected
Here is printer INF file:
[Version]
Signature = "$Windows NT$"
Class = USB
ClassGUID = {36FC9E60-C465-11CF-8056-444553540000}
Provider = SNBC
CatalogFile =WinUSBInstallation.cat
DriverVer = 05/10/2011,3.2.0.0
; ========== Manufacturer/Models sections ===========
[Manufacturer]
%ManufacturerName%=Standard,NTarm
[Standard.NTarm]
; POS/KIOSK Printers
%DeviceName% =USB_Install, USB\VID_154F&PID_154F
%DeviceName% =USB_Install, USB\VID_04ce&PID_04ce
%DeviceName% =USB_Install, USB\VID_154F&PID_1001
; ========== Class definition ===========
[ClassInstall32]
AddReg = ClassInstall_AddReg
[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%\system32\setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2
; =================== Installation ===================
[USB_Install]
Include = winusb.inf
Needs = WINUSB.NT
[USB_Install.Services]
Include =winusb.inf
Needs = WINUSB.NT.Services
[USB_Install.HW]
AddReg=Dev_AddReg
[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{ec55ee47-5758-4378-926b-68ed0aec8170}"
; =================== Strings ===================
[Strings]
Provider="SNBC"
Disk="SNBC Printer Driver"
REG_MULTI_SZ = 0x00010000
ManufacturerName="SNBC"
ClassName="Universal Serial Bus devices"
DeviceName="BT080-R"
Can anybody help me please?
I'm not sure the printer USB driver is supported on Windows IoT Core on Raspberry PI. You may contact the supplier of the peripheral to get the sys/inf files.Does this device support serial communication or Bluetooth? I think you can change to use a printer support serial port/Bluetooth instead of USB.

Powerpc systemsim-p8 does not boot debian 64 in ubuntu 64 16.04 LTS

I am trying to boot a debian ppc power8 ( or 7 ) in a simulation.
I followed the instructions in [1].
The only thing I manage to boot is an ram drive ( initrd ) with mambo kernel, but it is a closed source. I can't do much with it.
So , now I try to boot a mambo kernel ( with a bigus disk support ) from [2] with the debian image disk from [1].
The kernel manages to mount the drive, but i do not reach a login as depiced in [3].
[1] https://www14.software.ibm.com/webapp/set2/sas/f/pwrfs/pwrfsinstall.html.
[2] https://github.com/rpsene/linux.git
[3]
9415446: (688292884): [^[[32m OK ^[[0m] Reached target Local File Systems.
729612844: (688490282): Starting LSB: Raise network interfaces....
730353740: (689231178): Starting Trigger Flushing of Journal to Persistent Storage...
731308417: (690185857): Starting Create Volatile Files and Directories...
736470477: (695348428): udev-finish (1378) used greatest stack depth: 10752 bytes left
753931943: (712810985): [^[[32m OK ^[[0m] Started Copy rules generated while the root was ro.
765419589: (724298838): [^[[32m OK ^[[0m] Started Trigger Flushing of Journal to Persistent Storage.
804041342: (762920770): [^[[32m OK ^[[0m] Started Create Volatile Files and Directories.
804330683: (763210111): Starting Update UTMP about System Reboot/Shutdown...
815762188: (774642735): [^[[32m OK ^[[0m] Started Update UTMP about System Reboot/Shutdown.
817676182: (776556815): systemd-journald[1213]: Received request to flush runtime journal from PID 1
1076627432: (1035512412): [^[[32m OK ^[[0m] Started udev Coldplug all Devices.
Did you try this one https://github.com/open-power-sdk/power-simulator? This is the version I have uploaded last year. (bug report are welcome).
Also, you can get free Power VMs at https://minicloud.parqtec.unicamp.br/minicloud/
I have got the simulator up and running:
https://pastebin.com/ibGPeEFu
cloudusr#mambo:~$ ssh root#172.19.98.109
The authenticity of host '172.19.98.109 (172.19.98.109)' can't be established.
ECDSA key fingerprint is SHA256:x4/jPYq6SggOeSPOlQaxJlucih6elJLqog+i4P/euxY.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.19.98.109' (ECDSA) to the list of known hosts.
root#172.19.98.109's password:
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root#debianle:~# cat /proc/cpuinfo
processor : 0
cpu : POWER9 (raw), altivec supported
clock : 2000.000000MHz
revision : 2.0 (pvr 004e 0200)
timebase : 512000000
platform : PowerNV
model : Mambo,Simulated-System
machine : PowerNV Mambo,Simulated-System
firmware : OPAL
I've booted systemsim a bunch of times with ubuntu userspace. Do you have a copy of the disk image somewhere I can try? Is the sim userspace LE or BE?

udevadm to retrieve device attribute

OS: Ubuntu 16.04
Ethernet chip: Intel I210
Ethernet driver: igb
I've looked into my etherent device attribute.
By typing the command
udevadm info -p -a /sys/class/net/eth0
I got the following information:
looking at device '/devices/pci0000:00/0000:00:1c.2/0000:02:00.0/net/eth0':
KERNEL=="eth0"
SUBSYSTEM=="net"
DRIVER==""
ATTR{mtu}=="1500"
ATTR{type}=="1"
ATTR{netdev_group}=="0"
ATTR{flags}=="0x1003"
ATTR{speed}=="1000"
ATTR{dormant}=="0"
ATTR{addr_assign_type}=="0"
ATTR{dev_id}=="0x0"
ATTR{duplex}=="full"
ATTR{gro_flush_timeout}=="0"
ATTR{iflink}=="2"
ATTR{addr_len}=="6"
ATTR{address}=="0c:c4:7a:12:b4:e4"
ATTR{operstate}=="up"
ATTR{carrier_changes}=="2"
ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"
ATTR{tx_queue_len}=="1000"
ATTR{dev_port}=="0"
ATTR{ifalias}==""
ATTR{ifindex}=="2"
ATTR{link_mode}=="0"
ATTR{carrier}=="1"
looking at parent device '/devices/pci0000:00/0000:00:1c.2/0000:02:00.0':
KERNELS=="0000:02:00.0"
SUBSYSTEMS=="pci"
DRIVERS=="igb"
ATTRS{irq}=="18"
ATTRS{subsystem_vendor}=="0x15d9"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x020000"
ATTRS{index}=="1"
ATTRS{label}==" Intel Ethernet controller#1 i210"
ATTRS{driver_override}=="(null)"
ATTRS{consistent_dma_mask_bits}=="64"
ATTRS{dma_mask_bits}=="64"
ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f"
ATTRS{device}=="0x1533"
ATTRS{enable}=="1"
ATTRS{msi_bus}=="1"
ATTRS{local_cpulist}=="0-3"
ATTRS{vendor}=="0x8086"
ATTRS{subsystem_device}=="0x1533"
ATTRS{numa_node}=="-1"
ATTRS{d3cold_allowed}=="1"
Some questions below:
what is the relationship between "device" and "parent device"
Are these attributes retrieved from firmware ( on device ) or BIOS or driver ?
Is it possible to modify the attribute value ?
I ask this is because as you may know, Ubuntu 15.10 and newer version has taken the rule of predictable network interface names. For the onboard device, it will be recognized as "enox" and x means its index.
Unfortunately, on my host, my two ethernets have the same index and this causes the race condition. If I did not revert back to the original network interface naming rule, the boot is gonna take about 4 mins.
I suspect it's the firmware issue.

How does Linux Kernel know where to look for driver firmware?

I'm compiling a custom kernel under Ubuntu and I'm running into the problem that my kernel doesn't seem to know where to look for firmware. Under Ubuntu 8.04, firmware is tied to kernel version the same way driver modules are. For example, kernel 2.6.24-24-generic stores its kernel modules in:
/lib/modules/2.6.24-24-generic
and its firmware in:
/lib/firmware/2.6.24-24-generic
When I compile the 2.6.24-24-generic Ubuntu kernel according the "Alternate Build Method: The Old-Fashioned Debian Way" I get the appropriate modules directory and all my devices work except those requiring firmware such as my Intel wireless card (ipw2200 module).
The kernel log shows for example that when ipw2200 tries to load the firmware the kernel subsystem controlling the loading of firmware is unable to locate it:
ipw2200: Detected Intel PRO/Wireless 2200BG Network Connection
ipw2200: ipw2200-bss.fw request_firmware failed: Reason -2
errno-base.h defines this as:
#define ENOENT 2 /* No such file or directory */
(The function returning ENOENT puts a minus in front of it.)
I tried creating a symlink in /lib/firmware where my kernel's name pointed to the 2.6.24-24-generic directory, however this resulted in the same error. This firmware is non-GPL, provided by Intel and packed by Ubuntu. I don't believe it has any actual tie to a particular kernel version. cmp shows that the versions in the various directories are identical.
So how does the kernel know where to look for firmware?
Update
I found this solution to the exact problem I'm having, however it no longer works as Ubuntu has eliminated /etc/hotplug.d and no longer stores its firmware in /usr/lib/hotplug/firmware.
Update2
Some more research turned up some more answers. Up until version 92 of udev, the program firmware_helper was the way firmware got loaded. Starting with udev 93 this program was replaced with a script named firmware.sh providing identical functionality as far as I can tell. Both of these hardcode the firmware path to /lib/firmware. Ubuntu still seems to be using the /lib/udev/firmware_helper binary.
The name of the firmware file is passed to firmware_helper in the environment variable $FIRMWARE which is concatenated to the path /lib/firmware and used to load the firmware.
The actual request to load the firmware is made by the driver (ipw2200 in my case) via the system call:
request_firmware(..., "ipw2200-bss.fw", ...);
Now somewhere in between the driver calling request_firmware and firmware_helper looking at the $FIRMWARE environment variable, the kernel package name is getting prepended to the firmware name.
So who's doing it?
From the kernel's perspective, see /usr/src/linux/Documentation/firmware_class/README:
kernel(driver): calls request_firmware(&fw_entry, $FIRMWARE, device)
userspace:
- /sys/class/firmware/xxx/{loading,data} appear.
- hotplug gets called with a firmware identifier in $FIRMWARE
and the usual hotplug environment.
- hotplug: echo 1 > /sys/class/firmware/xxx/loading
kernel: Discard any previous partial load.
userspace:
- hotplug: cat appropriate_firmware_image > \
/sys/class/firmware/xxx/data
kernel: grows a buffer in PAGE_SIZE increments to hold the image as it
comes in.
userspace:
- hotplug: echo 0 > /sys/class/firmware/xxx/loading
kernel: request_firmware() returns and the driver has the firmware
image in fw_entry->{data,size}. If something went wrong
request_firmware() returns non-zero and fw_entry is set to
NULL.
kernel(driver): Driver code calls release_firmware(fw_entry) releasing
the firmware image and any related resource.
The kernel doesn't actually load any firmware at all. It simply informs userspace, "I want a firmware by the name of xxx", and waits for userspace to pipe the firmware image back to the kernel.
Now, on Ubuntu 8.04,
$ grep firmware /etc/udev/rules.d/80-program.rules
# Load firmware on demand
SUBSYSTEM=="firmware", ACTION=="add", RUN+="firmware_helper"
so as you've discovered, udev is configured to run firmware_helper when the kernel asks for firmware.
$ apt-get source udev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Need to get 312kB of source archives.
Get:1 http://us.archive.ubuntu.com hardy-security/main udev 117-8ubuntu0.2 (dsc) [716B]
Get:2 http://us.archive.ubuntu.com hardy-security/main udev 117-8ubuntu0.2 (tar) [245kB]
Get:3 http://us.archive.ubuntu.com hardy-security/main udev 117-8ubuntu0.2 (diff) [65.7kB]
Fetched 312kB in 1s (223kB/s)
gpg: Signature made Tue 14 Apr 2009 05:31:34 PM EDT using DSA key ID 17063E6D
gpg: Can't check signature: public key not found
dpkg-source: extracting udev in udev-117
dpkg-source: unpacking udev_117.orig.tar.gz
dpkg-source: applying ./udev_117-8ubuntu0.2.diff.gz
$ cd udev-117/
$ cat debian/patches/80-extras-firmware.patch
If you read the source, you'll find that Ubuntu wrote a firmware_helper which is hard-coded to first look for /lib/modules/$(uname -r)/$FIRMWARE, then /lib/modules/$FIRMWARE, and no other locations. Translating it to sh, it does approximately this:
echo -n 1 > /sys/$DEVPATH/loading
cat /lib/firmware/$(uname -r)/$FIRMWARE > /sys/$DEVPATH/data \
|| cat /lib/firmware/$FIRMWARE > /sys/$DEVPATH/data
if [ $? = 0 ]; then
echo -n 1 > /sys/$DEVPATH/loading
echo -n -1 > /sys/$DEVPATH/loading
fi
which is exactly the format the kernel expects.
To make a long story short: Ubuntu's udev package has customizations that always look in /lib/firmware/$(uname -r) first. This policy is being handled in userspace.
Wow this is very useful information and it led me to the solution for my problem when making a custom USB kernel module for a device requiring firmware.
Basically, every Ubuntu brings a new rehash of hal,sysfs,devfs,udev,and so on...and things just change. In fact I read they stopped using hal.
So let's reverse engineer this yet again so it's pertinent to the latest [Ubuntu] systems.
On Ubuntu Lucid (the latest at time of writing), /lib/udev/rules.d/50-firmware.rules is used. This file calls the binary /lib/udev/firmware, where magic happens.
Listing: /lib/udev/rules.d/50-firmware.rules
# firmware-class requests, copies files into the kernel
SUBSYSTEM=="firmware", ACTION=="add", RUN+="firmware --firmware=$env{FIRMWARE} --devpath=$env{DEVPATH}"
The magic should be something along these lines (source: Linux Device Drivers, 3rd Ed., Ch. 14: The Linux Device Model):
echo 1 to loading
copy firmware to data
on failure, echo -1 to loading and halt firmware loading process
echo 0 to loading (signal the kernel)
then, a specific kernel module receives the data and pushes it to the device
If you look at Lucid's source page for udev, in udev-151/extras/firmware/firmware.c, the source for that firmware /lib/udev/firmware binary, that's exactly what goes on.
Excerpt: Lucid source, udev-151/extras/firmware/firmware.c
util_strscpyl(datapath, sizeof(datapath), udev_get_sys_path(udev), devpath, "/data", NULL);
if (!copy_firmware(udev, fwpath, datapath, statbuf.st_size)) {
err(udev, "error sending firmware '%s' to device\n", firmware);
set_loading(udev, loadpath, "-1");
rc = 4;
goto exit;
};
set_loading(udev, loadpath, "0");
Additionally, many devices use an Intel HEX format (textish files containing checksum and other stuff) (wiki it i have no reputation and no ability to link). The kernel program ihex2fw (called from Makefile in kernel_source/lib/firmware on .HEX files) converts these HEX files to an arbitrary-designed binary format that the Linux kernel then picks up with request_ihex_firmware, because they thought reading text files in the kernel was silly (it would slow things down).
On current Linux systems, this is handled via udev and the firmware.agent.
Linux 3.5.7 Gentoo, I have the same issue.
SOLVED:
emerge ipw2200-firmware
Then go to /usr/src/linux
make menucofig
on device driver, remove all wirless drivers don't needed, set Intell 2200 as module and recompile.
make
make modules_install
cp arch/x86/boot/bzImage /boot/kernel-yourdefault

Resources