libpynq  (release 5EID0-2023 version 0.3.0 of 2024-04-25 09:42 )
version.c
Go to the documentation of this file.
1 /*
2 Copyright (c) 2023 Eindhoven University of Technology
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22 #include <libpynq.h>
23 
24 /**********************
25  * WARNING
26  * only change the numbers in these 4 #defs; do not change anything else
27  * the libpynq version in doxygen ryb.doxy is updated automatically based
28  * on the next 4 lines
29  **********************/
30 #define LIBPYNQ_RELEASE "5EID0-2023"
31 #define LIBPYNQ_VERSION_MAJOR 0
32 #define LIBPYNQ_VERSION_MINOR 3
33 #define LIBPYNQ_VERSION_PATCH 0
39 };
40 
41 #undef LOG_DOMAIN
42 #define LOG_DOMAIN "version"
43 
44 void print_version(void) {
45  arm_shared t;
46  version_t volatile *hardwareVersion =
47  (version_t volatile *)arm_shared_init(&t, axi_version_0, 4096);
48  printf("Bitstream version: %d.%d.%d\r\n", hardwareVersion->major,
49  hardwareVersion->minor, hardwareVersion->patch);
50  printf("Libpynq release %s version %d.%d.%d\r\n", libpynq_version.release,
52  if (libpynq_version.major != hardwareVersion->major) {
53  pynq_error(
54  "ERROR: the bitstream (hardware) and the libpynq library versions "
55  "are incompatible. Please update your SD-card image and libpynq "
56  "library.\n");
57  } else if (libpynq_version.minor > hardwareVersion->minor) {
58  printf("INFO: the libpynq library is newer than the bitstream (hardware). "
59  "Please check if there is a newer version of the SD-card image.\n");
60  } else if (libpynq_version.minor < hardwareVersion->minor) {
61  printf(
62  "INFO: the bitstream (hardware) is newer than the libpynq library. "
63  "Please check if there is a newer version of the libpynq library.\n");
64  }
65  arm_shared_close(&t);
66 }
67 
68 void check_version(void) {
69  arm_shared t;
70  version_t volatile *hardwareVersion =
71  (version_t volatile *)arm_shared_init(&t, axi_version_0, 4096);
72  if (libpynq_version.major != hardwareVersion->major) {
73  print_version();
74  }
75  arm_shared_close(&t);
76 }
check_version
void check_version(void)
Definition: version.c:19
version_t::patch
uint32_t patch
Definition: version.h:67
libpynq_version
const version_t libpynq_version
Definition: version.c:12
pynq_error
#define pynq_error(...)
Definition: log.h:118
LIBPYNQ_VERSION_MINOR
#define LIBPYNQ_VERSION_MINOR
Definition: version.c:32
version_t::major
uint32_t major
Definition: version.h:65
arm_shared_t
Definition: arm_shared_memory_system.h:39
arm_shared_close
void arm_shared_close(arm_shared *handle)
Definition: arm_shared_memory_system.c:70
print_version
void print_version(void)
Definition: version.c:18
LIBPYNQ_RELEASE
#define LIBPYNQ_RELEASE
Definition: version.c:30
LIBPYNQ_VERSION_PATCH
#define LIBPYNQ_VERSION_PATCH
Definition: version.c:33
arm_shared_init
void * arm_shared_init(arm_shared *handle, const uint32_t address, const uint32_t length)
Definition: arm_shared_memory_system.c:32
LIBPYNQ_VERSION_MAJOR
#define LIBPYNQ_VERSION_MAJOR
Definition: version.c:31
version_t::minor
uint32_t minor
Definition: version.h:66
version_t
Definition: version.h:63
libpynq.h
version_t::release
uint8_t release[64]
Definition: version.h:64