RTC DS1307 on Dragonboard 410c


#1

Hi, i am new to dragonboard and rtc DS1307. So, i don’t have much idea about these and kernel. I am interested in using the DragonBoard 410c for applications where the power is disconnected frequently and no internet connection available. If anyone can guide me how to wiring DS1307 in dragon board, installation instructions and enable it?
Regards


#2

Hardware:

You can find here a tutorial with an I2C light sensor. If not using any mezzanine board, you will need to interface a level shifter to shift Dragonboard 1.8v signaling to RTC DS1307 5v signaling, A previous topic (I2C0 Not working) contains a schematics example (DO NOT use TXB010x level shifter btw, prefer BSS138, PCA9306… I2C compatible ICs).

Software:

You will need to rebuild the Linux kernel with DS1307 driver (CONFIG_RTC_DRV_DS1307=y). Since I2C is not dynamically enumerable, you have to add an i2c slave node to the device-tree (hardware description) (arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi), something like this:

i2c@78b6000 {
/* On Low speed expansion */`
    label = "LS-I2C0";
    status = "okay";
    rtc@68 {
        compatible = "maxim,ds1307";
        reg = <0x68>; /* I2C address */
    };
};

Then rebuild kernel, DTB, generate bootimg and flash.


#3

thank you for the guidance but i dont know how to rebuild the kernel.I will check that one in internet and try.


#4

This information is available in releases notes: http://builds.96boards.org/releases/dragonboard410c/linaro/debian/latest/, cf How to get and customize the kernel source code.

You need a toolchain for cross-compilation:

$ mkdir toolchain
$ wget releases.linaro.org/components/toolchain/binaries/latest/aarch64-linux-gnu/gcc-*-x86_64_aarch64-linux-gnu.tar.xz
$ tar -xf gcc-*-x86_64_aarch64-linux-gnu.tar.xz -C ./toolchain --strip-components=1

The kernel sources:

$ git clone http://git.linaro.org/landing-teams/working/qualcomm/kernel.git
$ cd kernel
$ git checkout origin/release/qcomlt-4.14 -b my-custom-4.14

You can now compile the kernel:

$ export ARCH=arm64
$ export CROSS_COMPILE=`pwd`/../toolchain/bin/aarch64-linux-gnu-
$ make defconfig && make -j4
$ mkdir db410c-modules
$ make modules_install INSTALL_MOD_PATH=./db410c-modules

Pack generated kernel(Image) and DTB(apq8016-sbc.dtb) in a bootimg

$ gzip -c arch/arm64/boot/Image > Image.gz
$ cat Image.gz arch/arm64/boot/dts/qcom/apq8016-sbc.dtb > Image.gz+dtb
$ echo "not a ramdisk" > ramdisk.img
$ abootimg --create boot-db410c.img -k Image.gz+dtb -r ramdisk.img \
      -c pagesize=2048 -c kerneladdr=0x80008000 -c ramdiskaddr=0x81000000 \
      -c cmdline="root=/dev/mmcblk0p10 rw rootwait console=tty0 console=ttyMSM0,115200n8"

Flash bootimage

$ fastboot flash boot boot-db410c.img

Install modules
You need to copy modules installed in db410c-modules directory (e.g. db410c-modules/lib/modules/4.14.0-00132-ge3e0a10) to the /lib/modules directory on your target. You can perform this transfer either via USB key, SD Card or network.


#6

I have tried the steps to rebuild kernel when i use these command in dragon board410c I got error in this step:
$ git clone http://git.linaro.org/landing-teams/working/qualcomm/kernel.git
error in resolving deltas


#7

Can you copy the tool output to a pastebin or github gist and provide a link?


#8

just cloned from scratch this morning without any prob btw.


#9

This morning i again tried to clone and i get this error:
linaro@linaro-alip:~$ git clone http://git.linaro.org/landing-teams/working/qualcomm/kernel.git
Cloning into ‘kernel’…
remote: Counting objects: 6366801, done.
remote: Compressing objects: 100% (959905/959905), done.
fatal: Out of memory, calloc failed
fatal: index-pack failed

After getting this error, i again flashed image of linaro-debian:
http://builds.96boards.org/releases/dragonboard410c/linaro/debian/latest/dragonboard410c_sdcard_install_debian-283.zip
then try to clone:
linaro@linaro-alip:~$ git clone -n https://git.linaro.org/landing-teams/working/qualcomm/kernel.git
Cloning into ‘kernel’…
remote: Counting objects: 6366801, done.
remote: Compressing objects: 100% (959905/959905), done.
error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

when the receiving object is 80% db410c is freeze for 10-15min and then error message.


#10

Ok. I see.

These instructions are for running on your PC. The DB410C doesn’t really
have enough memory to grab the entire git repo.

You can do this on the DB410C if you really have to but you would need to
attach a swap partition somehow (and not mind that it’s slow).


#11

I don’t know how to run these instructions in windows pc. Will you please elaborate it.


#12

The instructions are for a GNU/Linux PC of some sort. I don’t run it myself but Ubuntu seems a popular choice at the moment.

It is also possible you might be able to build using Windows subsystem for Linux (which came out of beta in the Fall Creator’s Update). This is a compatibility layer that allows you to run many Ubuntu programs using the Windows kernel instead of the Linux kernel. In principle that allows you to run the cross-compilers in Windows.


#13

Hi @ane

Running out of memory while cloning the kernel onto the 410c is fully expected. The git-clone operation requires just over 1GB of memory, however the 410c only has 1GB of memory. To work around this you can turn on zram, or add a swap space. For zram, follow in instructions HERE. Ignore the note at the top of the page that says you need to turn on zram and rebuild the kernel, since the 17.09 kernel zram has been turned on by default (@ndec the wiki needs updating).

Once you get past the git clone running out of memory, the next issue you will run into is you are going to run out of storage space on the eMMC to build the kernel. To work around this you need to format a SDCard and do all of the clone and compile work on the SDCard.

Quite some time ago I learned how to compile and install the kernel on the 410c. Take a look at THIS thread, and near the bottom I give a full set of instructions. Beware this was a long time ago and minor things are always changing so the instructions may not be 100% correct.

Full disclosure: I am an employee of Qualcomm Canada, any opinions I have expressed in this or any other post may not reflect the opinions of my employer.


#14

I follow all the instruction and successfully installed and partition SD card. After sd card intallation i try to rebuild kernel but i got error in following steps:
linaro@linaro-alip:/usr/src/linux-4.0.0/kernel$ make defcongif distro.config
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig


*** Configuration file “.config” not found!


*** Please run some configurator (e.g. “make oldconfig” or
*** “make menuconfig” or “make xconfig”).


scripts/kconfig/Makefile:36: recipe for target ‘silentoldconfig’ failed
make[3]: *** [silentoldconfig] Error 1
Makefile:543: recipe for target ‘silentoldconfig’ failed
make[2]: *** [silentoldconfig] Error 2
make[1]: *** No rule to make target ‘defcongif’. Stop.
Makefile:522: recipe for target ‘__build_one_by_one’ failed
make: *** [__build_one_by_one] Error 2

After getting this error I reflash db410c sd card partion and follow the steps of
http://builds.96boards.org/releases/dragonboard410c/linaro/debian/latest/
to get and customize the kernel source code and in this case i got error in this step:
linaro@linaro-alip:/usr/src/linux-4.9.56/kernel$ sudo mkdir db410c-modules
linaro@linaro-alip:/usr/src/linux-4.9.56/kernel$ make modules_install KERNELRELEASE=4.9.56-linaro-lt-qcom INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH = ./db410c-modules
make: *** empty variable name. Stop.
And
linaro@linaro-alip:/usr/src/linux-4.9.56/kernel$ ./skales/mkbootimg --kernel arch/arm64/boot/Image.gz --ramdisk initrd.img-4.9.56-linaro-lt-qcom --output boot-db410c.img --dt dt.img --pagesize 2048 --base 0x80000000 --cmdline "$cmdline"
Can’t open arch/arm64/boot/Image.gz

If anyone can give me some suggestion regarding these error and tell me my mistake.


#15

@ljking, the wiki says

If you are not using the DragonBoard410c, you will need to rebuild the kernel using CONFIG_ZRAM=m and CONFIG_ZSMALLOC=m Kconfig option.

It looks correct to me, no?

I am referring to this page:


#16

This looks like a typo to me. Don’t you mean make defconfig distro.config?


#17

Hi @ndec:

The create swap space using zram guide says you need to rebuild the kernel to include the zram module, however the release notes for 17.09 say that zram module is now included by default (Bug Fixed: Enable zram) . Hence, I believe the Kconfig option is already set and there is no need to rebuild the kernel, just turn zram on with the scripts Steps part of the guide. You actually enabled the zram module in distro.config on Sept 26th, 2017 see https://bugs.96boards.org/show_bug.cgi?id=558

Full disclosure: I am an employee of Qualcomm Canada, any opinions I have expressed in this or any other post may not reflect the opinions of my employer.


#18

hey @ljking,

i know what I have done :wink:

In the link I sent about the zram guide, it says that “you need to rebuild the kernel if you are not using the DB410c”. Where do you see that we have to rebuild the kernel? Which page are you looking at?

nico


#19

Oops, my mistake. Obviously I didn’t read the instructions very carefully. :frowning: I skimmed the instructions and read “DragonBoard410c, you will need to rebuild the kernel”. The instructions are correct as written.

Full disclosure: I am an employee of Qualcomm Canada, any opinions I have expressed in this or any other post may not reflect the opinions of my employer.


#21

My mistake. i will do it again.
I am little bit confuse could you please explain me.
I am doing all these to setup rtc ds1307 in dragon board. Following are the steps that i am doing according to

  • SD card install, partition and mount
  • fetch kernel sources and build them
  • build the boot img and install it on to the boot partition

Yet I haven’t done rebuild successfully but i want to know in above steps when should I change in device tree (arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi)
Is it after kernel clone and before build them?


#22

Yes.

Or more generally… you can edit the sources at any time you like after you have downloaded them but, after making changes, you must return to the make -j4 Image dtbs modules step and recommence the instructions from there.