Skip to content

Commit

Permalink
Launch dtb processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalBlk committed Jul 4, 2022
1 parent fa8e827 commit ac0c346
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
52 changes: 29 additions & 23 deletions launch
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,6 @@ CONFIG = {
}
}

BOOTARGS_DTS_TEMPLATE = """
/dts-v1/;
/plugin/;
&{{/chosen}} {{
bootargs = "{}";
}};
"""


def setboard(name):
setvar('board', name)
Expand Down Expand Up @@ -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']


Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions sys/dts/launch.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

/dts-v1/;
/plugin/;

&{/chosen} {
bootargs = "BOOTARGS";
};
3 changes: 3 additions & 0 deletions sys/dts/rpi3.dts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#address-cells = <1>;
#size-cells = <1>;

chosen {
};

memory@0 {
reg = <0x00 0x3c000000>;
device_type = "memory";
Expand Down

0 comments on commit ac0c346

Please sign in to comment.