From ac0c346811d9932e375dded767cbf7d5acbe20bc Mon Sep 17 00:00:00 2001 From: MichalBlk Date: Mon, 4 Jul 2022 08:21:21 +0200 Subject: [PATCH] Launch dtb processing. --- launch | 52 ++++++++++++++++++++++++++-------------------- sys/dts/launch.dts | 7 +++++++ sys/dts/rpi3.dts | 3 +++ 3 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 sys/dts/launch.dts diff --git a/launch b/launch index a82cf3d634..f27b3523ba 100755 --- a/launch +++ b/launch @@ -157,15 +157,6 @@ CONFIG = { } } -BOOTARGS_DTS_TEMPLATE = """ -/dts-v1/; -/plugin/; - -&{{/chosen}} {{ - bootargs = "{}"; -}}; -""" - def setboard(name): setvar('board', name) @@ -305,20 +296,6 @@ class RENODE(Launchable): gdbport = getvar('config.gdbport', failok=False) self.options += [f'-e machine StartGdbServer {gdbport}'] - with open('bootargs.dts', 'w') as bootargs_dts_file: - bootargs_dts_file.write( - BOOTARGS_DTS_TEMPLATE.format(' '.join(getvar('config.args'))) - ) - subprocess.check_call( - 'dtc -O dtb -o bootargs.dtbo bootargs.dts', shell=True - ) - dtb = os.path.join('sys/dts/', '{}.dtb'.format(getvar('board'))) - subprocess.check_call( - 'fdtoverlay -i {} -o {} bootargs.dtbo'.format(dtb, dtb), shell=True - ) - os.remove('bootargs.dts') - os.remove('bootargs.dtbo') - self.options += ['-e start'] @@ -419,6 +396,33 @@ def setup_terminal(): subprocess.run(['stty', 'cols', str(cols), 'rows', str(rows)]) +def prepare_dtb(): + dts = os.path.join('sys/dts/', '{}.dts'.format(getvar('board'))) + if not os.path.isfile(dts): + return + + try: + with open('launch.dts', 'w') as launch_dts: + with open('sys/dts/launch.dts', 'r') as launch_tmpl_dts: + s = launch_tmpl_dts.read() + args = ' '.join(getvar('config.args')) + launch_dts.write(s.replace('BOOTARGS', args)) + + subprocess.check_call( + 'dtc -O dtb -o launch.dtbo launch.dts', shell=True + ) + dtb = os.path.join('sys/dts/', '{}.dtb'.format(getvar('board'))) + subprocess.check_call( + 'fdtoverlay -i {} -o {} launch.dtbo'.format(dtb, dtb), shell=True + ) + finally: + try: + os.remove('launch.dts') + os.remove('launch.dtbo') + except OSError: + pass + + if __name__ == '__main__': setup_terminal() @@ -458,6 +462,8 @@ if __name__ == '__main__': if not os.path.isfile(getvar('config.kernel')): raise SystemExit('%s: file does not exist!' % getvar('config.kernel')) + prepare_dtb() + sim_name = getvar('config.simulator', failok=False) # Create simulator launcher diff --git a/sys/dts/launch.dts b/sys/dts/launch.dts new file mode 100644 index 0000000000..67e1f5dd52 --- /dev/null +++ b/sys/dts/launch.dts @@ -0,0 +1,7 @@ + +/dts-v1/; +/plugin/; + +&{/chosen} { + bootargs = "BOOTARGS"; +}; diff --git a/sys/dts/rpi3.dts b/sys/dts/rpi3.dts index 400022159e..8e223d2f1a 100644 --- a/sys/dts/rpi3.dts +++ b/sys/dts/rpi3.dts @@ -10,6 +10,9 @@ #address-cells = <1>; #size-cells = <1>; + chosen { + }; + memory@0 { reg = <0x00 0x3c000000>; device_type = "memory";