enable the SAMA5D2 ADC Under Linux - does not work on linux4sam-2020.04

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

korapera
Posts: 2
Joined: Fri Oct 30, 2020 8:18 am

enable the SAMA5D2 ADC Under Linux - does not work on linux4sam-2020.04

Fri Oct 30, 2020 2:23 pm

I am using SAMA5D27-SOM1-EK1 board & I need to use the internal ADC of SAMA5D27 in my project .

I downloaded buildroot as instructions given in : https://www.linux4sam.org/bin/view/Linux4SAM/BuildRoot & built the OS to boot from microSD card. The OS boots and no issues with that.

I used following OS components & defconfig files to config each component:
- make atmel_sama5d27_som1_ek_mmc_dev_defconfig
- AT91 Bootstrap 3 : using sama5d27_som1_eksd1_uboot_defconfig for config.
- U-boot : using sama5d27_som1_ek_mmc1_defconfig for config.
- kernel : linux4sam-2020.04

I followed this guide to enable the ADC : http://ww1.microchip.com/downloads/en/A ... 03250a.pdf

I edited file : at91-sama5d27_som1_ek.dts and changed "status" to "okay"

Code: Select all

adc: adc@fc030000 {
				vddana-supply = <&vddana>;
				vref-supply = <&advref>;

				status = "okay";
			};
I checked the kernel device drivers and both ADC drivers are enabled :
in Linux/arm 5.4.41-linux4sam-2020.04 Kernel Configuration,
Device Drivers > Industrial I/O support > Analog to digital converters

<*> Atmel AT91 ADC
<*> Atmel AT91 SAMA5D2 ADC

Then to build the kernel, I did on buildroot base directory :
$ make linux-rebuild

Then to create the sdcard image I did,
$ make

Then I use this newly built image to boot the eval. board & when I enter command as given in : https://www.linux4sam.org/bin/view/Linu ... 2ADCDevice

Code: Select all

dmesg|grep at91-sama5d2_adc
it doesn't output any text and adc device name doesn't appear as explained on the guide.

When I enter other commands, it gives following error message which seems ADC is not enabled :

Code: Select all

ls /sys/bus/iio/devices/iio\:device0
ls: cannot access '/sys/bus/iio/devices/iio:device0': No such file or directory
Also I noticed that, at91-sama5d27_som1_ek.dtb was available on following two folders:
  • /home/user/buildroot-at91/output/build/linux-linux4sam-2020.04/arch/arm/boot/dts
  • /home/user/buildroot-at91/output/images
However, it was not getting copied to boot partition of the microSD card when the OS image is built
microSD card boot partition has only following files :
  • boot.bin
  • sama5d27_som1_ek.itb
  • u-boot.bin
  • uboot.env
I tried copying the file at91-sama5d27_som1_ek.dtb
manually to microSD card's boot partition. But still the ADC does not work in the newly build OS image.

Could anyone point out if I've missed some step or if I have done something wrong here?

If I'm doing something wrong here, can you please correct me ? and please guide me to do it in the proper way as I could not find any information on linux4sam.org or anywhere else on this issue.

Thanks & Regards
Kora
blue_z
Location: USA
Posts: 2131
Joined: Thu Apr 19, 2007 10:15 pm

Re: enable the SAMA5D2 ADC Under Linux - does not work on linux4sam-2020.04

Sat Oct 31, 2020 2:04 am

korapera wrote: Then to build the kernel, I did on buildroot base directory :
$ make linux-rebuild

Then to create the sdcard image I did,
$ make

...
Could anyone point out if I've missed some step or if I have done something wrong here?
You seem to be encountering an incomplete build and/or install when trying to do a partial rebuild consisting of just a DT blob.
Building & installing the Linux kernel "package" has gotten a bit complex with the Device Tree, and maybe you're in a corner case.
Since I'm not used to the newer commands, for DT changes I prefer to manually delete three files, .stamp_built, .stamp_target_installed, and .stamp_images_installed from the output/build/linux-* directory, and issue a single 'make' command.

korapera wrote: Also I noticed that, at91-sama5d27_som1_ek.dtb was available on following two folders:
  • /home/user/buildroot-at91/output/build/linux-linux4sam-2020.04/arch/arm/boot/dts
  • /home/user/buildroot-at91/output/images
You need to "notice" more than the mere existence of files.
Verify that the file's creation timestamp indicates that the directory contains a rebuilt/reinstalled version of that file.
You neglect to mention it, but output/images/sdcard.img is the most salient file because that is created last and therefore should have the freshest timestamp (i.e. more recent than when the 'make' was issued).

korapera wrote: However, it was not getting copied to boot partition of the microSD card when the OS image is built
microSD card boot partition has only following files :
  • boot.bin
  • sama5d27_som1_ek.itb
  • u-boot.bin
  • uboot.env
The latest Atmel booting scheme uses a FIT image, which bundles a kernel image and DT blob(s) into a single file.
You apparently didn't notice that the original 'make' did not install a .dtb in the SDcard image, and yet it seemed to boot okay.
So there should be no expectation that a rebuild would suddenly install a .dtb file.

korapera wrote: I tried copying the file at91-sama5d27_som1_ek.dtb manually to microSD card's boot partition. But still the ADC does not work in the newly build OS image.
You haven't done anything to actually change the boot sequence (i.e. the bootcmd environment variable of U-Boot), so whatever .dtb you install will be ignored and the (original) .itb will be used.

Regards
korapera
Posts: 2
Joined: Fri Oct 30, 2020 8:18 am

Re: enable the SAMA5D2 ADC Under Linux - does not work on linux4sam-2020.04

Sat Oct 31, 2020 4:37 pm

thanks blue_z, appreciate your response & detailed explanations.

I tried what you've suggested as shown below :

I have a working buildroot-at91 build, I did following things on that :

1. edited : at91-sama5d27_som1_ek.dts - changed to status = "okay" (folder: /home/user/buildroot-at91/output/build/linux-linux4sam-2020.04/arch/arm/boot/dts/)

Code: Select all

adc: adc@fc030000 {
				vddana-supply = <&vddana>;
				vref-supply = <&advref>;

				status = "okay";
			};
2. deleted following files from buildroot-at91/output/build/linux-linux4sam-2020.04
- .stamp_built
- .stamp_images_installed
- .stamp_target_installed

3. from folder : /buildroot-at91
- make

4. flashed the new image built by make & booted eval. board
5. still ADC is not activated, see below terminal output :

Code: Select all

#
# dmesg|grep at91-sama5d2_adc
#
#
# ls /sys/bus/iio/devices/iio\:device0
ls: /sys/bus/iio/devices/iio:device0: No such file or directory
I'm new to buildroot and embedded linux, so bare with me if I'm asking too basic questions, I tried to follow Microchip documentations & look up in forums. I was unable to find an answer.

Any help will be highly apricated to solve this issue.
blue_z
Location: USA
Posts: 2131
Joined: Thu Apr 19, 2007 10:15 pm

Re: enable the SAMA5D2 ADC Under Linux - does not work on linux4sam-2020.04

Wed Nov 04, 2020 1:08 am

korapera wrote: I tried what you've suggested as shown below :
The salient advice provided for troubleshooting this issue was to pay attention to the create/modify timestamps of the files involved.
Seems like you prefer to ignore checking any intermediate steps (performed by the 'make' scripts between your #3 and #4), and just test the final step, i.e. booting and accessing the device node.


korapera wrote: Any help will be highly apricated to solve this issue.
Verify that the .dtb and .itb files in the output/images/ directory are newer than the .dts file that you edited.

You can inspect the Device Tree that is in use at /proc/device-tree/ of the root filesystem of a live system (i.e. verify that the DT changes are in place).

Regards

Return to “Development Tools”

Who is online

Users browsing this forum: No registered users and 8 guests