Project

General

Profile

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

Alex Seferidis, 07/15/2025 01:56 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
``` php
27
$mac = $_POST['mac'];
28
$mac_Arr = explode(":", $mac);
29
	
30
if (count($mac_Arr) != 6) {
31
	echo "MAC address ERROR";
32
	exit();
33
}
34
	
35
36
chdir("/data/firmware/htdocs");
37
$output = shell_exec('dd if=/dev/mmcblk0 skip=7170 of=mac.img bs=512 count=1');
38
	
39
$filesize = filesize('mac.img');
40
$fp = fopen('mac.img', 'rb');
41
$binary = fread($fp, $filesize);
42
fclose($fp);
43
		
44
$binary[0] = chr(hexdec($mac_Arr[0]));
45
$binary[1] = chr(hexdec($mac_Arr[1]));
46
$binary[2] = chr(hexdec($mac_Arr[2]));
47
$binary[3] = chr(hexdec($mac_Arr[3]));
48
$binary[4] = chr(hexdec($mac_Arr[4]));
49
$binary[5] = chr(hexdec($mac_Arr[5]));
50
	
51
$fp = fopen('mac_new.img', 'wb');
52
fwrite($fp, $binary);
53
fclose($fp);
54
		
55
$output = shell_exec('dd if=mac_new.img of=/dev/mmcblk0 seek=7170 bs=512 count=1');
56
```