File: genmem.py

package info (click to toggle)
msp430mcu 20120406-2
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 66,788 kB
  • ctags: 627,664
  • sloc: ansic: 605,160; python: 838; sh: 165; makefile: 37; sed: 2
file content (46 lines) | stat: -rw-r--r-- 1,474 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright (c) 2011, Peter A. Bigot, licensed under New BSD (see COPYING)
# This file is part of msp430mcu (http://sourceforge.net/projects/mspgcc/)
#
# Generate linker scripts to define the memory regions supported on
# particular MSP430 chips.

import sys
import csv
import os
import msp430mcu

msp430mcu.load_devices()

def writeMemory (mcu, mdir):
    try:
        os.makedirs(mdir)
    except OSError, e:
        pass

    mpath = os.path.join(mdir, 'memory.x')
    outf = file(mpath, 'w')
    outf.write(mcu.regionSection())
    outf.write('''
REGION_ALIAS("REGION_TEXT", rom);
REGION_ALIAS("REGION_DATA", ram);
REGION_ALIAS("REGION_FAR_ROM", far_rom);
''')

    if 0 < mcu.infomem.segment_size:
        outf.write('PROVIDE (__info_segment_size = 0x%x);\n' % (mcu.infomem.segment_size,))
        if 0 < mcu.infod.origin:
            outf.write('PROVIDE (__infod = 0x%04x);\n' % (mcu.infod.origin,))
        if 0 < mcu.infoc.origin:
            outf.write('PROVIDE (__infoc = 0x%04x);\n' % (mcu.infoc.origin,))
        if 0 < mcu.infob.origin:
            outf.write('PROVIDE (__infob = 0x%04x);\n' % (mcu.infob.origin,))
        if 0 < mcu.infoa.origin:
            outf.write('PROVIDE (__infoa = 0x%04x);\n' % (mcu.infoa.origin,))

for mcu in msp430mcu.KnownDevices:
    mdir = os.path.join(msp430mcu.analysis_dir, 'ldscripts', mcu.mcu)
    writeMemory(mcu, mdir)
    if mcu.mergeRegions(mcu.usbram, mcu.ram):
        writeMemory(mcu, os.path.join(mdir, 'nousb'))