Date on the BeagleBone - BelaPlatform/Bela GitHub Wiki

This material has been superseded. Visit learn.bela.io for the maintained version.

The BeagleBone Black and the BeagleBone Green have no on-board battery so that the system date gets lost at every reboot and get reset to the 26th of August 2013. This means that every time you power up the board, you may have troubles if you want to rely on the date for any of the things you are doing.

For this reason, the date on the board is set every time there is a chance or a need to do so. The date on the board is set to the same date as your computer in the following cases:

  • every time you connect to the IDE. The node.js server running on the board will ask the date to your web browser and use that value to set the date on the board.
  • the build scripts (build_project.sh or build_pd_heavy.sh) will set the date on the board invoking the date command on your machine, before copying the files to the board.
  • if you connect the board to a wired or wireless network which is connected to the internet, the clock on the board will probably be updated through the network.

Note that there are still a few cases when the date is not set, e.g.:

  • when the board runs in stand-alone mode, that is when it is powered through a battery or power supply, and it is not connected to any network
  • if the board is connected to the computer but you do not run the build scripts (build_project.sh or build_pd_heavy.sh) and you do not use the IDE.

The most immediate consequence of this is that you cannot rely on the date when operating in stand-alone mode. For instance, if you were to create some log files to log how a performer interacts with an instrument across multiple sessions, then if you were to rely on the date at the moment the program starts, you would probably end up overwriting your log files over and over again, because every time the program starts, the date would, as far as the board is concerned, always the same. As a workaround for this, you will want to make sure you check if a file exists before overwriting it. See the d-box example project for an example of how to do so.

The building process

The building process, which compiles the C/C++ files on the board into object files and then links them together to create the executable binary file which is ultimately executed, heavily relies on the modification date of the source and output files. Every time the build process is started, the make program, which takes care of it, checks if each output file is more recent than its respective source file. If that is the case, the output file is considered to be "up-to-date" and the build process is not repeated for that file. The underlying reason for this is that compiling files and linking them takes time and you do not want to re-compile all the files every time you change a line on one of them. The process described above works just fine in systems where the date is mostly monotonically increasing, where "mostly" means that occasional skews of a few seconds or fractions of seconds happen when the date is synchronized to an external server.

If the date on Bela is not synchronized with an external reference, troubles could happen during the build process. Typically, it could happen that a modified source file does not get recompiled, or the executable file does not get re-linked. An easy solution for this is to remove the .o build files and the executable file. This can be done by calling make with the projectclean target, as explained [here](The Bela Makefile).

Luckily, this should never be needed because, as mentioned above, all the operations that require building files take care of setting the date. Yet, it is good to remember it in case you ever get the weird behaviour of your changes to the source files not being reflected on the built program.