Mercurial > lcfOS
comparison python/stlink.py @ 121:347d7d8b96c0
Cleanup
author | Windel Bouwman |
---|---|
date | Sat, 12 Jan 2013 12:35:02 +0100 |
parents | f51791638cae |
children | 9f1094b1587a |
comparison
equal
deleted
inserted
replaced
120:bb08633510bf | 121:347d7d8b96c0 |
---|---|
61 FLASH_F4_CR_SER = 1 | 61 FLASH_F4_CR_SER = 1 |
62 FLASH_CR_MER = 2 | 62 FLASH_CR_MER = 2 |
63 FLASH_F4_CR_SNB = 3 | 63 FLASH_F4_CR_SNB = 3 |
64 FLASH_F4_CR_SNB_MASK = 0x38 | 64 FLASH_F4_CR_SNB_MASK = 0x38 |
65 FLASH_F4_SR_BSY = 16 | 65 FLASH_F4_SR_BSY = 16 |
66 | |
67 # flashloaders/stm32f4.s | |
68 loader_code_stm32f4 = bytes([ | |
69 0x07, 0x4b, | |
70 | |
71 0x62, 0xb1, | |
72 0x04, 0x68, | |
73 0x0c, 0x60, | |
74 | |
75 0xdc, 0x89, | |
76 0x14, 0xf0, 0x01, 0x0f, | |
77 0xfb, 0xd1, | |
78 0x00, 0xf1, 0x04, 0x00, | |
79 0x01, 0xf1, 0x04, 0x01, | |
80 0xa2, 0xf1, 0x01, 0x02, | |
81 0xf1, 0xe7, | |
82 | |
83 0x00, 0xbe, | |
84 | |
85 0x00, 0x3c, 0x02, 0x40 | |
86 ]) | |
87 | 66 |
88 def calculate_F4_sector(address): | 67 def calculate_F4_sector(address): |
89 """ | 68 """ |
90 from 0x8000000 to 0x80FFFFF | 69 from 0x8000000 to 0x80FFFFF |
91 4 sectors of 0x4000 (16 kB) | 70 4 sectors of 0x4000 (16 kB) |
108 def calcSectors(address, size): | 87 def calcSectors(address, size): |
109 off = 0 | 88 off = 0 |
110 sectors = [] | 89 sectors = [] |
111 while off < size: | 90 while off < size: |
112 sectornum, sectorsize = calculate_F4_sector(address + off) | 91 sectornum, sectorsize = calculate_F4_sector(address + off) |
113 #print('num: {0} size: {1:X} offset: {2}'.format(sectornum, sectorsize, off)) | |
114 sectors.append((sectornum, sectorsize)) | 92 sectors.append((sectornum, sectorsize)) |
115 off += sectorsize | 93 off += sectorsize |
116 return sectors | 94 return sectors |
117 | 95 |
118 class STLink: | 96 class STLink: |