Determine hardware version from commandline

When logged in as root, is there any way to tell which hardware version of the Banana Pi you are logged into? Some sort of hardware signature, or some combined metric??

which are you mean???, github???

Sorry, maybe wrong section for this question, but I mean: When logged in to a device, is there a way to know which BPi version (M1, M2, R2, W2, etc.) you are in?

it is easy to know which module are you use, all is not same. just check wiki page;

http://wiki.banana-pi.org/Main_Page

If you want only know device (not hw revision) you can use info from devicetree

[08:45] frank@bpi-r2-e:~$ cat /sys/firmware/devicetree/base/model
Bananapi BPI-R2[08:45] frank@bpi-r2-e:~$

Sounded like what I was looking for, but at my machine /sys/firmware is emptyā€¦

I understand I can visually inspect the hardware, but how about telling ā€œfrom insideā€ the machine: can software know which Bananpi it is running on?

Maybe kernel is too old and/or devicetree is mapped to /proc (imho first versions were here)

Also last official versions passing board in commandline to linux-kernel

cat /proc/cmdline
1 Like

Yes, /proc/cmdline has ā€œboard=bpi-m1ā€! Do all BPis have a similar board parameter on the kernel commandline??

(It seems the RPi I have access to does use /sys/firmware/devicetree/base/model, and it doesnā€™t have a board parameter on the kernel commandlineā€¦)

@frank-w Is there a more modern kernel than 3.4.112-sun7i for the M1?

I suggest combining these optionsā€¦the cmdline board parameter is banana pi specific (and only if uboot uses thisā€¦if you override bootargs this is gone)ā€¦model in devicetree is more device-independed (if you stay on arm architecture) and if kernel has devicetree included (imho 4.x).

I think m1 should have mainline-support so just build one by youselfā€¦i donā€™t know if there any ready-to-use kernels available.

You can try this and maybe copy config from it:

M1 should be this dts: https://github.com/frank-w/BPI-R2-4.14/blob/5.4-merged/arch/arm/boot/dts/sun7i-a20-bananapi.dts m1+: https://github.com/frank-w/BPI-R2-4.14/blob/5.4-merged/arch/arm/boot/dts/sun7i-a20-bananapi-m1-plus.dts

Maybe this helps (did not know if i got it this time): BananaPi bananian newer Kernel also found this (just replace kernel version to get newer one: https://watchmysys.com/blog/2015/07/building-linux-4-1-for-the-banana-pi/

1 Like

Hi pepa65,

for systems with u-boot support Iā€™m using this subroutine:

check_4_u_boot()
{
   U_BOOT_DIR=`ls /usr/lib | grep "u-boot-next-"` > /dev/null 2>&1
   if [ $? -eq 0 ]
   then
        echo "$P>      u-boot-next directory...:  $U_BOOT_DIR"
        HW=`ls /usr/lib | grep "u-boot-next-" | cut -d '-' -f5 | cut -d '_' -f1`
        DEFCONFIG=`find /usr/lib/u-boot -print | grep "defconfig"` > dev/null 2>&1
        if [ $? -eq 0 ]
        then
           HW_DET=`cat $DEFCONFIG | grep "CONFIG_DEFAULT_DEVICE_TREE" | cut -d '=' -f2 | tr -d '"' `
           echo "$P>      CONFIG_DEVICE_TREE......:  $HW_DET"
        fi
   else
	echo "$P!      NO u-boot-next support..!"
   fi
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Regards
WolliK

Yes, the OS running on my M1 does not seem to use u-boot-next, I only have a /usr/lib/u-boot directory and it doesnā€™t have any entries with defconfig.

these are many non-standard-checksā€¦at least on my images (r2/r64) there is no uboot-next source dir. i have them also not seen it on official images for these boards.

the boards supported by mainline-kernel should use them instead of the very very old 3.x one at least for security reasons. and then you have devicetree and can use the model property

Hi pepa65,

for my BPI M2 Zero Iā€™m running an old Debian version 3.xx with no u-boot support. On this system I read out the brand details from the script.bin file. But not all releases uses a script.bin file. Here is my subroutine to process the script.bin file:

check_4_script_bin()
{ 
	BIN2FEX=`sudo find / -name bin2fex` > /dev/null 2>&1
	if [ $? -eq 0 ]
	then
		SCRIPT_BIN=`sudo find /boot -name script.bin` > /dev/null 2>&1
		if [ $? -eq 0 ]
		then
			echo "$P>      Check script.bin file...:  $SCRIPT_BIN"
			echo ' '
			HW=`sudo $BIN2FEX -q $SCRIPT_BIN | grep "machine" | cut -d '"' -f2` 
			echo ' '
			echo "$P>      HW via script.bin.......:  $HW"
		else
			echo "$P!      No script.bin file found!" 
		fi
	fi	
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Regards
WolliK
1 Like

Thanks for the pointer. My machine didnā€™t come with bin2fex, so I built the Sunxi-tools and used them on the script.bin in /boot, with the result: ā€œorangepi-plusā€ (interesting, but I am sure I have a Banana Pi M1). Must be an artifact of the Ubuntu 16.04.6 LTS image that Iā€™m usingā€¦

Hi pepa65, Iā€™m using today ARMBIAN for my BPIā€™ā€˜s systems (different models) and RASPIAN for my RPIā€™ systems (also different models), so I donā€™t run into this kind of problems.

Regards Wolfgang

1 Like

Iā€™m considering switching to Armbian, more recent kernel too, better maintained. I would like to be running from the SATA harddrive, because I am worried about the SD card with all the writesā€¦

why not just move heavy written folders (like temp,var) to hdd and leave system on sdcardā€¦so you can restore/update/reinstall your system by replace the sdcard, but have not that write-load on it

Thatā€™s what I have now, /tmp on tmpfs, swap and /var on the harddrive. Is it hard to get most things on the HDD?

the easiest way getting most things to HDD is moving full rootfs and change root-var in cmdline (uboot bootargs). Here you need only kernel (at least with sata buildtin-not module) on sdcard and of course uboot+uenv.txt, basicly content of your boot-partition, root-partition can be on hdd

1 Like