grub2 takes root option from bios - buildroot

There are several devices to boot from them in my PC: HDD and USB flash.
If I just switch on PC than PC will use HDD with name sda.
If I push F2 key after PC will start and than select Boot from USB in BIOS than PC will use USB flash with name sdb1.
I have got problem with my grub-bios.cfg file because I need different configuration for 1) and for 2) Can grub2 ask BIOS which device BIOS wants to be booted?
This is grub-bios.cfg for case 1)
set default="0"
set timeout="10"
menuentry "BuildrootUSBFlash" {
linux /boot/bzImage root=/dev/sda rootwait console=tty1
}
This is grub-bios.cfg for case 2)
set default="0"
set timeout="10"
menuentry "BuildrootUSBFlash" {
linux /boot/bzImage root=/dev/sdb1 rootwait console=tty1
}
I try remove root=/dev/sdb1 Linux starting but after starting infinite waiting disk... I try change root=/dev/sdb1 to root=/dev/sdb but kernel panic...

Related

U-boot environment is not the same as Linux "fw_printenv"

I've build an image for my Jetson Nano with yocto using the meta-tegra layer.
This build is using u-boot as bootloader which is set to save the environment on an MMC partition (mmcblk0p14).
gdisk -l /dev/mmcblk0 shows the following:
Number Start (sector) End (sector) Size Code Name
...
14 20996096 20998143 1024.0 KiB 8300 UBOOTENV
...
And the sector size is 512.
I've then configured u-boot-tegra/include/configs/p3450-porg.h with:
...
/* Env is located in it's own partition */
#define CONFIG_ENV_IS_IN_MMC
#define CONFIG_SYS_MMC_ENV_DEV 1
#define CONFIG_ENV_OFFSET (20996096 * 512)
...
Where CONFIG_ENV_OFFSET = Start_Sector * Block_Size
This works fine (as far as I can see) as the environment is saved successfully to MMC when i use saveenv.
However, the environment i get when i print it in u-boot shell is NOT the same as when i print the environment with fw_printenv u-boot tool. I have set the /etc/fw_env.config to:
# Device name Device offset Env size
/dev/mmcblk0p14 0 0x2000
So what I've gathered is that, either the fw_env.config is set wrong or the u-boot environment is saved somewhere else on the MMC and no the partition 14.
Does anyone have suggestions to what i could try?
*****************************************************EDIT:*****************************************************
Doing dd if=/dev/mmcblk0p14 of=tmp.txt and reading the tmp.txt file shows the environment that the fw_printenv shows and not the environment I'm seeing in u-boot shell.
So something must be wrong in the u-boot-tegra/include/configs/p3450-porg.h configuration. I just wonder where it actually writes the environment to when i do a saveenv...
Any Idea what I can try to change?
As stated in the comments to the question, the offset is a 32-bit integer so attempting to give it the value of more than 4,294,967,295 (which 20996096 * 512 is) is not gonna work.
To fix it, I've rearranged my partition scheme to have my uboot environment partition as partition 1 instead of 14 and changed the fw_env.config and p3450-porg.h patch accordingly.

Passing Bootargs via Chosen node in Device Tree not working for Beaglebone Black

As per my understanding chosen node is used to send boot arguments to the kernel.
The following is the chosen node of the existing device code (am335x-bone-common.dtsi).
chosen {
stdout-path = &uart0;
};
So, I have modified chosen node to pass kernel arguments.
chosen {
bootargs = "console=ttyO0,115200 root=/dev/mmcblk0p2 rootfstype=ext3 rw rootwait";
stdout-path = &uart0;
};
While bringing up the board I encountered KERNEL PANIC,
Here is the log {https://pastebin.com/XHyrsmfG}
FYI: These are the u-boot commands issued on serial console(minicom) inorder to port kernel and devicetree using SDcard.
fatload mmc 0:1 0x81000000 zImage
fatload mmc 0:1 0x82000000 am335x-boneblack.dtb
bootz 0x81000000 - 0x82000000
As per my understanding chosen node is used to send boot arguments to the kernel.
Your understanding is incomplete.
As already mentioned in another answer, the kernel command line provided by the bootloader (i.e. U-Boot) is the actual list of parameters currently used when you boot the board.
For ARM Linux the default kernel configuration gives precedence to the bootloader's command line over the default kernel command string and the bootargs in the chosen node in the Device Tree.
The rationale according to U-Boot author/maintainer Wolfgang Denk seems to be that any hardcoded, built-in bootargs are inferior to bootargs that can be easily customized and supplied by a bootloader.
This is exactly what you are seeing.
There are actually three possible ARM kernel boot configuration choices:
Kernel command line type:
(X) Use bootloader kernel arguments if available
( ) Extend bootloader kernel arguments
( ) Always use the default kernel command string
If you want to always ignore the command line in U-Boot's bootargs variable (and the command line from the DT), but exclusively use the default kernel command string as defined in CONFIG_CMDLINE, then the kernel should be configured for the third choice (CONFIG_CMDLINE_FORCE) on that list.
Note that this list of choices is only available when CONFIG_ATAGS is enabled ("Support for the traditional ATAGS boot data passing").
The scheme that selects the DT bootargs is to use the existing kernel configuration, but simply delete that U-Boot environment variable (i.e. setenv bootargs).
If you change U-Boot's bootargs variable to an empty string as mentioned in another answer, the kernel will use its default kernel command string (CONFIG_CMDLINE) rather than the DT.
Also see How to set Linux kernel command line on ARM?
As per my understanding chosen node is used to send boot arguments to
the kernel. The following is the chosen node of the existing device
code (am335x-bone-common.dtsi).
chosen {
bootargs = "console=ttyO0,115200 root=/dev/mmcblk0p2 rootfstype=ext3 rw rootwait";
stdout-path = &uart0;
};
Looking at your pastie, the boot log says the command line is the following:
Kernel command line: console=ttyO0,115200
ip=10.0.0.111:10.0.0.4::255.255. 255.0 rw root=/dev/nfs
nfsroot=10.0.0.4:/home/dileep/beaglebone/rootfs,
And since you have also set the bootargs "bootargs = "console=ttyO0,115200 root=/dev/mmcblk0p2 rootfstype=ext3 rw rootwait";" in the devicetree wouldnt affect as uboot has already set those parameters, ie if same parameter is set in the device tree and in the tags (uboot), the one from the uboot tags will be chosen.
So you will have to clear up the bootargs set by u-boot.
1] setenv bootargs "";
2] saveenv
3] fatload mmc 0:1 0x81000000 zImage
4] fatload mmc 0:1 0x82000000 am335x-boneblack.dtb
5 bootz 0x81000000 - 0x82000000
For fresh building uboot, where the board is not programmed yet make sure in the u-boot configs you don’t have bootargs variable defined.

Raspbian echo device

I need to create an echo device for software tests under Raspbian.
The aim is a device, that returns everything. E.g. if I would send some data to a device (ls > /dev/tty30), I need this data back from this (or an equal) device.
Is there already a possibility out-of-the-shelf inside Raspian? (e.g. an echo device)
Can I create such a device by an serial null modem simulation?
Raspbian sure supports such behaviour:
root#raspberrypi:/root# mkfifo /dev/tty100
root#raspberrypi:/root# cat < /dev/tty100 |cat > /dev/tty100&
[1] 19024
root#raspberrypi:/root# echo hi > /dev/tty100
root#raspberrypi:/root# cat /dev/tty100
hi
^C

Not getting UUID from diskutil on OSX

Running Mac OSX 10.7.5
I want to enable NTFS on a USB3 external hard disk and need the UUID to do it (http://ntfsonmac.com) but diskutil is refusing to give me the UUID. I start with:
diskutil info /Volumes/HD-PCTU3/
then from this:
diskutil info disk2s1
Device Identifier: disk2s1
Device Node: /dev/disk2s1
Part of Whole: disk2
Device / Media Name: Untitled 1
Volume Name: HD-PCTU3
Escaped with Unicode: HD-PCTU3
Mounted: Yes
Mount Point: /Volumes/HD-PCTU3
Escaped with Unicode: /Volumes/HD-PCTU3
File System Personality: NTFS
Type (Bundle): ntfs
Name (User Visible): Windows NT File System (NTFS)
Partition Type: Windows_NTFS
OS Can Be Installed: No
Media Type: Generic
Protocol: USB
SMART Status: Not Supported
Total Size: 500.1 GB (500107804672 Bytes) (exactly 976773056 512-Byte-Blocks)
Volume Free Space: 499.9 GB (499896778752 Bytes) (exactly 976360896 512-Byte-Blocks)
Device Block Size: 512 Bytes
Read-Only Media: No
Read-Only Volume: Yes
Ejectable: Yes
Whole: No
Internal: No
but as can be seen there is no UUID displayed. Any ideas why and/or how to get the UUID?
The only way I've been able to find involves a somewhat poorly documented feature of the hfs.util.
Run the diskutil command and then copy/remember/save the Device Identifier:
diskutil info /Volumes/my_drive_label | grep "Device Identifier"
You can use the hfs.util with the Device Identifier (replacing disk2s1 below) from diskutil to (re)generate a UUID for your volume:
/System/Library/Filesystems/hfs.fs/hfs.util -s disk2s1
Keep in mind this won't work for every volume, if the volume is not an HFS drive than it may not work, and other Filesystem/*.fs/*.util commands may not have a -s verb to generate UUIDs.
UPDATE
In Yosemite and after the -s flag has been disabled at the source level. I haven't been able to find a pre-modified version of hfs.util, but you can do it yourself using the information found in this Superuser question, summarized here:
Download the hfs.util source from Apple and extract it to a temporary folder
Download hfs_fsctl.h from Apple and put it in the hfs.util folder
Change line 47 of hfsutil_jnl.c into #include <hfs_fsctl.h>
Change line 80 of hfsutil_main.c into #include <System/uuid/uuid.h>
Change line 81 of hfsutil_main.c into static unsigned char kFSUUIDNamespaceSHA1[] = {0xB3,0xE2,0x0F,0x39,0xF2,0x92,0x11,0xD6,0x97,0xA4,0x00,0x30,0x65,0x43,0xEC,0xAC}; (replacing the include line)
Also add #define HFS_UUID_SUPPORT 1 to hfsutil_main.c
There might still be something missing in the argument parsing section if the above doesn't work, please reference the Superuser question and comment if I've missed something.
Some people have also reported that it may be possible to use Gparted to change the UUID of a drive.
I'm on Mac OS X 10.6.8 and bought NTFS 4TB Seagate USB3.0 drive.
Plugged in, Mac allowed me to read files from it, but not write to it. When I select 'Get Info' for the volume/disk, I see 'You can read only' under 'Sharing & Permissions'.
I copied a large file from Windows 10 to the USB Drive, worked fine. I then downloaded the file to Mac, worked fine, but won't allow me to write anything from Mac to the USB drive, or make any changes to it eg. delete or rename files on the USB drive.
My reason for getting this USB drive formatted in NTFS was to copy files from Mac larger than 4GB to Windows for redundant backup, because of 4GB limit in FAT.
One solution I found online was to sudo echo UUID to /etc/fstab
When I diskutil info, I don't get UUID.
I also see the following extracts:
File System Personality: NTFS
Type (Bundle): ntfs
Name (User Visible): Windows NT File System (NTFS)
&
Read-Only Media: No
Read-Only Volume: Yes
Ejectable: Yes
My solution was to download Samsung NTFS for Mac Driver from:
https://www.seagate.com/au/en/support/downloads/item/samsung-ntfs-driver-master-dl/
After installation & reboot, I noticed the following changes:
When I select 'Get Info' for the volume/disk, I see 'You can read and write' under 'Sharing & Permissions'.
2.
File System Personality: UFSD_NTFS
Type (Bundle): ufsd_NTFS
Name (User Visible): Windows NT Filesystem
3.
Read-Only Media: No
Read-Only Volume: No
Ejectable: Yes
The readme file (pdf) that comes with the download says NTFS features also work in Mac for the USB drive.
Now I can read/write to the disk, and is also visible in Finder. I've tested read & write speeds with a 2GB file, and don't see any difference in performance/speed between the NTFS & HFS+ Journaled volumes.
Finally after 2 days of reading about sudo, hfs.util & diskutil, I can now get back to backing up data from Mac 10.6 to USB NTFS drive.

How to mount sd card to android source-built emulator?

I've built the android source code and run the emulator successfully except one thing - SD card couldn't be mounted. Here is how I tried to mount it.
1. create a sdcard.img by mksdcard tool under /out/host/linux-x86/bin/
mksdcard 256M out/target/product/generic/sdcard.img
sdcard.img is rw
run emulator with command line:
out/host/linux-x86/bin/emulator -sysdir out/target/product/generic/ -system out/target/product/generic/system.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/userdata.img -kernel prebuilt/android-arm/kernel/kernel-qemu -skindir sdk/emulator/skins -skin WVGA800 -scale 0.7 -memory 512 -partition-size 2024 -sdcard out/target/product/generic/sdcard.img
the file under /system/etc/vold.conf is ok.
system log shows:
<6>mmc0: new SD card at address e118
<6>mmcblk0: mmc0:e118 SU02G 256 MiB
<6> mmcblk0:
But the truth is that it failed to mount sdcard. It will get a "read only" error if trying to write data in /mnt/sdcard/
Anyone can help on this? thanks in advance.
just follow below step:
Goto the Android Virtual device manager
click New for create new Vitual device
Add Name and choose your package
Under hardware you just click New Button and then pop new Window
After select SdCard support in drop down list near Property
finally you have gotten emulator with SDCard support
First, emulator should work without any parameters by setting up the right environment variables as described here.
Create sd card image file sdcard.img (on linux, using dd /dev/zero to make empty file filled by zeroes suffices)
Make FAT or ext4 filesystem on it (on linux, mkdosfs path/to/sdcard.img) It should be possible to skip this step and format it from within emulator, too.
Then run
emulator -sdcard path/to/sdcard.img
In my case, it shows in Settings as "usb storage", instead of "sd card".