How to Set the Time Zone on Forlinx OK-MX9352 Single Board Computer?

OK-MX9352-C Single Board Computer

OK-MX9352-C Single Board Computer

1. NTP Synchronization Time

The iMX9352 chip supports the Network Time Protocol (NTP) synchronized time function, which allows users to obtain time information from an NTP server by entering the NTP command at the terminal. NTP timing can be easily achieved by ensuring that the board can connect to an external network.

root@ok-mx93:~# ntpdate cn.pool.ntp.org           //NTP time synchronization 
	
8 May 02:15:12 [146.081931] systemd-journald[183]: Oldest entry in
/run/log/journal/eff65e923ca4437f8903c36fd7aa0d79/system.journal is older than the configured file retention duration (1month), suggesting rotation.
ntpdate[782]: ste[146.100692] systemd-journald[183]:
/run/log/journal/eff65e923ca4437f8903c36fd7aa0d79/system.journal: Journal header limits reached or header out-of-date, rotating.
p time server 78.46.102.180 offset +32373024.924745 sec 
root@ok-mx93:~# date
Mon May	8 02:15:25 -08 2023

2. Time Zone Setting

The /usr/share/zoneinfo/ path contains the time zone files supported by imx93; changing the time zone is simply a matter of replacing /etc/localtime with the time zone file in that path.

As an example, let's use the time zone of Shanghai for the eastern eight zones, and soft link /usr/share/zoneinfo/Asia/Shanghai to /etc/localtime: first delete /etc/localtime, and then generate the soft link:

root@ok-mx93:~# rm /etc/localtime     //Delete the original time zone file
root@ok-mx93:~# ln -s	/usr/share/zoneinfo/Asia/Shanghai	/etc/localtime	//generate soft link	
root@ok-mx93:~# date -R	//check time zone Tue, 
03 May 2022 02:27:36 +0800	

3. Modify the time zone file in the file system image

When using batch burning, to replace the time zone file board by board is obviously unrealistic, so we can directly modify the file system zip➔modify the time zone file to repackage the file system➔replace the zip in the burning tool➔burn with the new burning tool.

The path to the iMX93 file system in the source code is
OKMX93-linux-sdk/OKMX93-linux-fs/rootfs.

Run the following command in the Ubuntu development environment:

forlinx@ubuntu:~$ cd ok-mx93/OKMX93-linux-sdk/
forlinx@ubuntu:~/ok-mx93/OKMX93-linux-sdk$ rm OKMX93-linux-fs/rootfs/etc/localtime
forlinx@ubuntu:~/ok-mx93/OKMX93-linux-sdk$ ln -s OKMX93-linux-fs/rootfs/usr/share/zoneinfo/Asia/Shanghai OKMX93-linux-fs/rootfs/etc/localtime
forlinx@ubuntu:~/ok-mx93/OKMX93-linux-sdk$ . environment-setup-aarch64-toolchain //Execute environment variables 
forlinx@ubuntu:~/ok-mx93/OKMX93-linux-sdk$ ./build.sh mkfs	//Repackage the file system