示例#1
0
 def runTest(self):
     kit = devkit.factory(_stm32)
     memsize = _stm32['BootStart']
     randmem = bytearray(memsize)
     for i in xrange(memsize):
         randmem[i] = random.randint(0, 255)
     kit.write(0x08000000, randmem)
     self.assertEqual(b''.join([bytes(kit.blocks[i]) for i,_ in enumerate(kit.blockaddr)]),
                      bytes(randmem))
示例#2
0
 def runTest(self):
     kit = devkit.factory(_stm32)
     self.assertIsInstance(kit, devkit.STM32DevKit)
     kit.write(0x08000000, unhexlify('FCFF0120997E0000417E0000417E0000'))
     kit.fix_bootloader()
     self.assertEqual(unhexlify('FCFF012001000E00'),
                      kit.blocks[0][:8])
     self.assertEqual(unhexlify('4FF6FC70C2F20100854647F69960C0F200000047'),
                      kit.blocks[len(kit.blockaddr)-1][-20:])
示例#3
0
 def runTest(self):
     kit = devkit.factory(_stm32)
     memsize = _stm32['BootStart']
     randmem = bytearray(memsize)
     for i in xrange(memsize):
         randmem[i] = 255
     for i in xrange(self.blkcount):
         size = random.randint(1, memsize)
         addr = random.randint(0, memsize - size)
         randblk = bytearray(size)
         for j in xrange(size):
             randblk[i] = random.randint(0, 255)
         randmem[addr:addr+size] = randblk
         kit.write(0x08000000 + addr, randblk)
         self.assertEqual(b''.join([bytes(kit.blocks[i] if i in kit.blocks else
                                          b'\xff'*(end_addr - start_addr))
                                    for i, (start_addr, end_addr) in enumerate(kit.blockaddr)]),
                          bytes(randmem))
示例#4
0
 def runTest(self):
     kit = devkit.factory(_stm32)
     self.assertRaises(IndexError,
         lambda: kit.write(0x08000000 - 1, b'\xff'))
     self.assertRaises(IndexError,
         lambda: kit.write(0x08000000 + _stm32['BootStart'], b'\xff'))
示例#5
0
 def runTest(self):
     bootinfo = dict(_stm32)
     for mcu in devkit.STM32DevKit._supported:
         bootinfo['McuType'] = mcu
         self.assertIsInstance(devkit.factory(bootinfo), devkit.STM32DevKit)