Project

General

Profile

U-boot (plus MAC address) » History » Version 5

Alex Seferidis, 07/15/2025 02:00 PM

1 1 Alex Seferidis
# U-boot (plus MAC address)
2
3 3 Alex Seferidis
**SOS** : do not use u-boot from Yocto
4 1 Alex Seferidis
Use u-boot provided by Rockchip SDK
5
6
1. copy board.c to /arch/arm/mach-rockchip
7
8
2. file: configs/rk3568_defconfig
9
CONFIG_BOOTDELAY=5
10
11
Note: Read Docs: /home/SDK_4_19/docs
12
13
use these commands to build uboot:
14
15
```
16
./build.sh device/rockchip/rk356x/BoardConfig-evb2-lp4x-v10.mk rk3566-evb2-lp4x-v10.mk
17
./build.sh uboot
18
```
19 2 Alex Seferidis
20
<img src="uboot.png" width="50%">
21 4 Alex Seferidis
22
With this uboot MAC address can be written to flash. The uboot read MAC address and provides it to Linux.
23
24
example how to write MAC with PHP script (this script runs on device):
25
26 5 Alex Seferidis
mmcblk0 is u-boot partiotion
27
Mac address info is located after 7170 bytes (or in HEX at address 0x1C02)
28
29 4 Alex Seferidis
``` php
30
$mac = $_POST['mac'];
31
$mac_Arr = explode(":", $mac);
32
	
33
if (count($mac_Arr) != 6) {
34
	echo "MAC address ERROR";
35
	exit();
36
}
37
	
38
39
chdir("/data/firmware/htdocs");
40
$output = shell_exec('dd if=/dev/mmcblk0 skip=7170 of=mac.img bs=512 count=1');
41
	
42
$filesize = filesize('mac.img');
43
$fp = fopen('mac.img', 'rb');
44
$binary = fread($fp, $filesize);
45
fclose($fp);
46
		
47
$binary[0] = chr(hexdec($mac_Arr[0]));
48
$binary[1] = chr(hexdec($mac_Arr[1]));
49
$binary[2] = chr(hexdec($mac_Arr[2]));
50
$binary[3] = chr(hexdec($mac_Arr[3]));
51
$binary[4] = chr(hexdec($mac_Arr[4]));
52
$binary[5] = chr(hexdec($mac_Arr[5]));
53
	
54
$fp = fopen('mac_new.img', 'wb');
55
fwrite($fp, $binary);
56
fclose($fp);
57
		
58
$output = shell_exec('dd if=mac_new.img of=/dev/mmcblk0 seek=7170 bs=512 count=1');
59
```