File: commands.py

package info (click to toggle)
solo1-cli 0.1.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 464 kB
  • sloc: python: 2,168; makefile: 36
file content (73 lines) | stat: -rw-r--r-- 1,590 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding: utf-8 -*-
#
# Copyright 2019 SoloKeys Developers
#
# Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
# http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
# http://opensource.org/licenses/MIT>, at your option. This file may not be
# copied, modified, or distributed except according to those terms.


class STM32L4:
    class options:
        nBOOT0 = 1 << 27
        nSWBOOT0 = 1 << 26


class SoloExtension:
    version = 0x14
    rng = 0x15


class SoloBootloader:
    write = 0x40
    done = 0x41
    check = 0x42
    erase = 0x43
    version = 0x44
    reboot = 0x45
    st_dfu = 0x46
    disable = 0x47

    CommandBoot = 0x50
    CommandEnterBoot = 0x51
    CommandEnterSTBoot = 0x52
    CommandRNG = 0x60
    CommandProbe = 0x70

    TAG = b"\x8C\x27\x90\xf6"


class DFU:
    class type:
        SEND = 0x21
        RECEIVE = 0xA1

    class bmReq:
        DETACH = 0x00
        DNLOAD = 0x01
        UPLOAD = 0x02
        GETSTATUS = 0x03
        CLRSTATUS = 0x04
        GETSTATE = 0x05
        ABORT = 0x06

    class state:
        APP_IDLE = 0x00
        APP_DETACH = 0x01
        IDLE = 0x02
        DOWNLOAD_SYNC = 0x03
        DOWNLOAD_BUSY = 0x04
        DOWNLOAD_IDLE = 0x05
        MANIFEST_SYNC = 0x06
        MANIFEST = 0x07
        MANIFEST_WAIT_RESET = 0x08
        UPLOAD_IDLE = 0x09
        ERROR = 0x0A

    class status:
        def __init__(self, s):
            self.status = s[0]
            self.timeout = s[1] + (s[2] << 8) + (s[3] << 16)
            self.state = s[4]
            self.istring = s[5]