Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Iterate all of the apps, and see if we can make this work based on
# having apps compiled for the correct addresses. If so, great! If
# not, error for now.
to_flash_apps = []
app_address = address
for app in apps:
# Ask the app where we can put it that is greater than or equal
# to the current address we are looking at.
next_loadable_address = app.get_next_loadable_address(app_address)
if next_loadable_address == app_address:
to_flash_apps.append(app)
app_address += app.get_size()
elif next_loadable_address != None:
# Need to add padding.
padding_app = PaddingApp(next_loadable_address - app_address)
to_flash_apps.append(padding_app)
app_address += padding_app.get_size()
to_flash_apps.append(app)
app_address += app.get_size()
else:
logging.error('Trying to find a location for app "{}"'.format(app))
logging.error(' Address to use is {:#x}'.format(app_address))
raise TockLoaderException('Could not load apps due to address mismatches')
# Actually write apps to the board.
app_address = address
if self.args.bundle_apps:
# Tockloader has been configured to bundle all apps as a single