-
Notifications
You must be signed in to change notification settings - Fork 4
/
pcanflash.h
69 lines (63 loc) · 2.1 KB
/
pcanflash.h
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
/*
* pcanflash.h - flash program for PCAN routers
*
* Copyright (C) 2021 PEAK System-Technik GmbH
*
* linux@peak-system.com
* www.peak-system.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Author: Oliver Hartkopp (socketcan@hartkopp.net)
* Maintainer(s): Stephane Grosjean (s.grosjean@peak-system.com)
*
*/
#include <stdint.h>
#define CAN_ID 0x7E7
#define SET_STARTADDR (1 << 0) // 01
#define SET_CHECKSUM (1 << 1) // 02
#define SET_LENGTH (1 << 2) // 04
#define SET_ERASE_OK (1 << 5) // 20
#define SET_CHECKSUM_OK (1 << 6) // 40
#define SET_VERIFY_OK (1 << 7) // 80
#define CAN2FLASH_STATE_REQUEST 0x00
#define CAN2FLASH_SET_STARTADDRESS 0x01
#define CAN2FLASH_SET_BLOCKSIZE 0x02
#define CAN2FLASH_SET_CHECKSUM 0x03
#define CAN2FLASH_ERASE_SECTOR 0x04
#define CAN2FLASH_START_PROGRAMMING 0x05
#define CAN2FLASH_VERIFY 0x06
#define CAN2FLASH_SWITCH_TO_BOOTLOADER 0x07
#define CAN2FLASH_RESET_REQUEST 0x0F
#define CAN2FLASH_START_FLASH_HI 0x10
#define CAN2FLASH_START_FLASH_LO 0x11
#define CAN2FLASH_END 0x12
#define CAN2FLASH_GET_JSON_DESCRIPTOR 0x13
typedef struct {
uint32_t address;
uint32_t len;
uint16_t crc;
} __attribute__((packed)) block_t;
typedef struct {
uint8_t str[16];
uint16_t version;
uint16_t day;
uint16_t month;
uint32_t year;
uint16_t dummy[3];
uint16_t mode;
uint16_t count;
block_t block[1];
} __attribute__((packed)) crc_array_t;