Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

storing the build date inside firmware #13

Closed
ghost opened this issue Sep 3, 2015 · 5 comments
Closed

storing the build date inside firmware #13

ghost opened this issue Sep 3, 2015 · 5 comments
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Sep 3, 2015

This has been at the back of my mind for a while, that two firmwares built by two people in different parts of the world, with the same tools, will get different checksums because the date that the binary was built was different. Included the date that the binary was built in a firmware is less useful than the date of the last commit in git. If 20 years from now, someone built the current firmware, having 2035-MM-DD as the date in the firmware version string would be less useful than seeing 2015-07-14.

Can the following line in firmware/scripts/airspy_fw-version.py
print '#define AIRSPY_FW_BUILD_DATE "' + date.today().isoformat() + '"'
be changed to something along the lines of the following:
print '#define AIRSPY_FW_CHECKIN_DATE "' + git.show(['--pretty=format:%ai']).partition(' ')[0] + '"'
and version_string in firmware/airspy_m0/airspy_m0.c be changed as well, to use AIRSPY_FW_CHECKIN_DATE instead of AIRSPY_FW_BUILD_DATE or whatever you decide.

Feel free to close this, and go "nope, not going to happen", I just watched the below CCC video and it made me think about the different hashes again, and it probably put me in the mood for a mad rant :)
https://media.ccc.de/browse/conferences/camp2015/camp2015-6657-how_to_make_your_software_build_reproducibly.html

@bvernoux
Copy link
Member

bvernoux commented Sep 3, 2015

Nice fix, I will apply it and check all is ok

@bvernoux bvernoux self-assigned this Sep 3, 2015
bvernoux added a commit that referenced this issue Sep 6, 2015
@bvernoux
Copy link
Member

bvernoux commented Sep 6, 2015

Done thanks for your contribution

@bvernoux bvernoux closed this as completed Sep 6, 2015
@ghost
Copy link
Author

ghost commented Sep 6, 2015

In case there is any problem with:
print '#define AIRSPY_FW_CHECKIN_DATE "' + git.show(['--pretty=format:%ai']).partition(' ')[0] + '"'
It can be replaced by:
print '#define AIRSPY_FW_CHECKIN_DATE "' + git.log('-1','--format=%ai').partition(' ')[0] + '"'
Which is probably easier to understand what it is doing

@bvernoux
Copy link
Member

bvernoux commented Sep 6, 2015

I have tested it with success but any feedback is welcome and if some
configuration have problems we could use
print '#define AIRSPY_FW_CHECKIN_DATE "' + git.log(['-1
--format=%cd']).partition(' ')[0] + '"'
(if that solve problems)

On 6 September 2015 at 13:24, itsbert notifications@github.com wrote:

In case there is any problem with:
print '#define AIRSPY_FW_CHECKIN_DATE "' +
git.show(['--pretty=format:%ai']).partition(' ')[0] + '"'
It can be replaced by:
print '#define AIRSPY_FW_CHECKIN_DATE "' + git.log(['-1
--format=%cd']).partition(' ')[0] + '"'


Reply to this email directly or view it on GitHub
#13 (comment).

@ghost
Copy link
Author

ghost commented Sep 6, 2015

No, no problem here. it works for me. I just think that it is slightly less obtuse and more easily understood, but the name of the define, AIRSPY_FW_CHECKIN_DATE, helps to make things clear.

EDIT:
Actually there may be a problem, when I run "git show --pretty=format:%ai" in a local clone of another git that I have (liquid-dsp), I see the following:
$ git show --pretty=format:%ai
2015-07-21 18:49:53 -0400
But when I run it in airspy/firmware I see the following:
$ git show --pretty=format:%ai
2015-09-06 12:09:36 +0200
diff --git a/airspy_m0/airspy_m0.c b/airspy_m0/airspy_m0.c
index 805a829..9d8a7e6 100644
--- a/airspy_m0/airspy_m0.c
+++ b/airspy_m0/airspy_m0.c
@@ -74,7 +74,7 @@ volatile airspy_mcore_t set_packing = (airspy_mcore_t *)((&cm0_data_share)+2);
uint8_t
const usb_bulk_buffer = (uint8_t*)0x20004000;
uint8_t spiflash_buffer[W25Q80BV_PAGE_LEN];
-char version_string[] = VERSION_STRING " " AIRSPY_FW_GIT_TAG " "AIRSPY_FW_BUILD_DATE;
+char version_string[] = VERSION_STRING " " AIRSPY_FW_GIT_TAG " "AIRSPY_FW_CHECKIN_DATE;^M
uint8_t version_string_strlen = sizeof(version_string);
typedef struct {
diff --git a/scripts/airspy_fw-version.py b/scripts/airspy_fw-version.py
index 5442580..104592a 100755
--- a/scripts/airspy_fw-version.py
+++ b/scripts/airspy_fw-version.py
@@ -13,7 +13,7 @@ if len(args)==1:
sys.stdout = open(args[0], 'w')
git=Repo(search_parent_directories=True).git
print '#define AIRSPY_FW_GIT_TAG "' + git.describe(tags=True,always=True,dirty=True,long=True) + '"'
- print '#define AIRSPY_FW_BUILD_DATE "' + date.today().isoformat() + '"'
+ print '#define AIRSPY_FW_CHECKIN_DATE "' + git.show(['--pretty=format:%ai']).partition(' ')[0] + '"'
else:
parser.print_help()
sys.exit(1)

I haven't used git from python so it's behaviour may be different than the command that I'm using. :

I also edited the post that I made to use "%ai" instead of "%cd"

@bvernoux bvernoux added this to the v1.0.0-rc7 milestone Apr 23, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant