Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct version_info {

extern volatile const struct version_info version_info;

void print_version_info(int verbose);
void print_version_info(const struct version_info *v);
```

#### `version.c`
Expand All @@ -74,15 +74,19 @@ volatile const struct version_info version_info = {
void print_version_info(const struct version_info *v)
{
printf(
"%s v%d.%d.%d %s %s %s\n"
" Compiled %s %s by %s on %s\n"
"%s v%d.%d.%d %s\n\r"
"Compiled %s %s by %s on %s\n\r"
"Image Start: 0x%x Size: %d\n\r"
"Image CRC: 0x%x\n",
v->product_name,
v->major, v->minor, v->patch,
v->vcs_id,
v->build_date, v->build_time,
v->build_date, v->build_time,
v->build_user, v->build_host
v->build_user, v->build_host,
v->image_start, v->image_size,
v->image_crc
);

}

void main(void)
Expand Down
7 changes: 6 additions & 1 deletion add_version_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import ctypes
import datetime
import os
import struct

import elf_reader
from crc32_forge import CRC32
Expand All @@ -60,6 +61,10 @@ class version_info(ctypes.LittleEndianStructure):
("build_host" , ctypes.c_char * 16),
("build_date" , ctypes.c_char * 16),
("build_time" , ctypes.c_char * 16),
("product_name" , ctypes.c_char * 32),
("major" , ctypes.c_int32),
("minor" , ctypes.c_int32),
("patch" , ctypes.c_int32),

("vcs_info_end" , ctypes.c_char * 16)
]
Expand All @@ -79,7 +84,7 @@ def fill_version_info(info):
dprint(info.vcs_id.decode(ENCODING))

info.build_user = bytes(getpass.getuser(), ENCODING)
info.build_host = bytes(platform.node(), ENCODING)
info.build_host = bytes(platform.node()[0:16], ENCODING)

mtime = datetime.datetime.fromtimestamp( os.path.getmtime(args.source) )
info.build_date = bytes(mtime.strftime("%Y-%m-%d"), ENCODING)
Expand Down