Skip to content

Commit 8e30c46

Browse files
committed
tools/linux.py: Simplify u-boot handling
Both bootargs and certain u-boot commands can be set via the devicetree. The bootargs are already passed via "/chosen/bootargs". U-boot's `bootcmd`, `bootdelay` and `baudrate` can be overriden in "/config/" when CONFIG_OF_CONTROL is set. Use proxy::kboot_set_uboot() to set these /config properties and drop the modification of the default environment in the u-boot image. Signed-off-by: Janne Grunau <[email protected]>
1 parent d78a021 commit 8e30c46

1 file changed

Lines changed: 13 additions & 32 deletions

File tree

proxyclient/tools/linux.py

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -87,46 +87,27 @@
8787
uboot_addr = u.memalign(2*1024*1024, len(uboot))
8888
print("Loading u-boot to 0x%x..." % uboot_addr)
8989

90-
bootenv_start = uboot.find(b"bootcmd=bootflow scan -b")
91-
bootenv_len = uboot[bootenv_start:].find(b"\x00\x00")
92-
bootenv_old = uboot[bootenv_start:bootenv_start+bootenv_len]
93-
bootenv = str(bootenv_old, "ascii").split("\x00")
94-
bootenv = list(filter(lambda x: not (
95-
x.startswith("baudrate") or
96-
x.startswith("boot_") or
97-
x.startswith("bootdelay=") or
98-
x.startswith("preboot=") or
99-
x.startswith("bootcmd")
100-
), bootenv))
90+
u.compressed_writemem(uboot_addr, uboot, True)
91+
p.dc_cvau(uboot_addr, uboot_size)
92+
p.ic_ivau(uboot_addr, uboot_size)
93+
94+
boot_addr = uboot_addr
10195

10296
if args.efi and initramfs is not None:
103-
bootcmd = "bootcmd=bootefi 0x%x:0x%x 0x%x:0x%x $fdtcontroladdr" % (kernel_base, kernel_size, initramfs_base, initramfs_size)
97+
bootcmd = "bootefi 0x%x:0x%x 0x%x:0x%x $fdtcontroladdr" % (kernel_base, kernel_size, initramfs_base, initramfs_size)
10498
elif initramfs is not None:
105-
bootcmd = "bootcmd=booti 0x%x 0x%x:0x%x $fdtcontroladdr" % (kernel_base, initramfs_base, initramfs_size)
99+
bootcmd = "booti 0x%x 0x%x:0x%x $fdtcontroladdr" % (kernel_base, initramfs_base, initramfs_size)
106100
elif args.efi:
107-
bootcmd = "bootcmd=bootefi 0x%x:0x%x $fdtcontroladdr" % (kernel_base, kernel_size)
101+
bootcmd = "bootefi 0x%x:0x%x $fdtcontroladdr" % (kernel_base, kernel_size)
108102
else:
109-
bootcmd = "bootcmd=booti 0x%x - $fdtcontroladdr" % (kernel_base)
110-
111-
if tty_dev is not None:
112-
bootenv.append("baudrate=%d" % tty_dev.baudrate)
113-
bootenv.append(bootcmd)
114-
bootenv.append("bootdelay=0")
115-
if args.bootargs is not None:
116-
bootenv.append("bootargs=" + args.bootargs)
103+
bootcmd = "booti 0x%x - $fdtcontroladdr" % (kernel_base)
117104

118-
bootenv_new = b"\x00".join(map(lambda x: bytes(x, "ascii"), bootenv))
119-
bootenv_new = bootenv_new.ljust(len(bootenv_old), b"\x00")
105+
p.kboot_set_uboot("bootcmd", bootcmd)
106+
p.kboot_set_uboot("bootdelay", "0")
120107

121-
if len(bootenv_new) > len(bootenv_old):
122-
raise Exception("New bootenv cannot be larger than original bootenv")
123-
uboot[bootenv_start:bootenv_start+bootenv_len] = bootenv_new
124-
125-
u.compressed_writemem(uboot_addr, uboot, True)
126-
p.dc_cvau(uboot_addr, uboot_size)
127-
p.ic_ivau(uboot_addr, uboot_size)
108+
if tty_dev is not None:
109+
p.kboot_set_uboot("baudrate", "%d" % tty_dev.baudrate)
128110

129-
boot_addr = uboot_addr
130111

131112
p.cpufreq_init()
132113
p.smp_start_secondaries()

0 commit comments

Comments
 (0)