summaryrefslogtreecommitdiff
path: root/prototype/fw/tools/patch_system_init.py
blob: a3e84f85ba9747e2fceb9e16558723f2a432dcdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python3

if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('input', type=argparse.FileType('r'), help='Input stm32****_system.c file')
    args = parser.parse_args()

    print('/* AUTOGENERATED FILE! Do not edit! */')
    print('/* This file was automatically patched by tools/patch_system_init.py */')
    print()
    print('extern unsigned int g_pfnVectors;')
    print()

    for line in args.input:
        if line.strip().startswith('SCB->VTOR'):
            print('    SCB->VTOR = (uint32_t)&g_pfnVectors;')
        else:
            print(line.rstrip())