element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Enchanted Objects
  • Challenges & Projects
  • Design Challenges
  • Enchanted Objects
  • More
  • Cancel
Enchanted Objects
Blog Review 9b: Atmel SMART SAMA5D4 Xplained Ultra - Set up ADC Buffer with Hardware Trigger Part 2
  • Blog
  • Forum
  • Documents
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 21 May 2015 7:39 PM Date Created
  • Views 114 views
  • Likes 2 likes
  • Comments 3 comments
  • sama5d4
  • enchanted_player
  • enchanted_objects
  • hardware
  • trigger
  • buffer
  • adc
  • xplained_ultra
  • atmel
  • linux
Related
Recommended

Review 9b: Atmel SMART SAMA5D4 Xplained Ultra - Set up ADC Buffer with Hardware Trigger Part 2

Jan Cumps
Jan Cumps
21 May 2015

I'm trying the Buffer and Hardware Trigger  capabilities of the SAMA5D4.

I follow the instructions of http://www.at91.com/linux4sam/bin/view/Linux4SAM/IioAdcDriver.

 

In Part 1, I enabled the hardware trigger from the linux prompt.

In this post, I'm testing the buffer with the test tool generic_buffer.

 

Building the Test Tool

 

generic_buffer is available as c source. There's a number of them available in different versions on the internet, but not all compile for this board (or for my tool chain).

I steered away from examples that use the be16toh function. I got errors when I compiled those.

There are also versions without that function.

I used (without further analysis, just because it was the first hit) kernel-rsbac-source-3.0.2-1mdv-1-1-mdv2011.0.i586.rpm.59587983/usr/src/3.0.2-rsbac-1mdv/drivers/staging/iio/Documentatio…

Use the one from the atmel git: https://raw.githubusercontent.com/linux4sam/linux-at91/master/drivers/staging/iio/Documentation/generic_buffer.c

 

Run the Test Tool

 

My first run is with the analog input connected to ground. I'm doing the exercise while writing the blog, so what you see here is exactly as it happens.

 

 

As a first step, I load my compiled program

 

rz -e -b -X generic_buffer
chmod +x generic_buffer

 

and execute the steps documented in part 1:

 

modprobe at91_adc
echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_voltage0_en
echo "fc034000.adc-dev0-continuous" > /sys/bus/iio/devices/iio:device0/trigger/current_trigger
echo 100 > /sys/bus/iio/devices/iio:device0/buffer/length
echo 1 > /sys/bus/iio/devices/iio:device0/buffer/enable

 

And now the moment suprême: running that binary:

 

# Don't use at91_adc when working with a 'device tree' linux distro ./generic_buffer -n at91_adc -t fc034000.adc-dev0-continuous -l 2

 

./generic_buffer -n fc034000.adc -t fc034000.adc-dev0-continuous -l 2

 

where:

  • at91_adc is the IIO driver
  • fc034000.adc is the IIO driver
  • fc034000.adc-dev0-continuous is the trigger name
  • 2 is the buffer lenght (I would expect 100 here because I echo 100 to buffer/length a few lines higher. I'm following the advice of linux4sam here.

 

And here I fail. Failed to find the at91_adc

My error message is related to the driver. I'm posting a new post on the at91.com forum to see what's wrong.

 

hold on...

 

 

While my post is open on the at91 forum, I'm continuing with investigations.

 

Here's where the code fails:

    /* Find the device requested */
    dev_num = find_type_by_name(device_name, "device");
    if (dev_num < 0) {
        printf("Failed to find the %s\n", device_name);
        ret = -ENODEV;
        goto error_ret;
    }
    printf("iio device number being used is %d\n", dev_num);

 

I'm going to check how find_type_by_name() works, and check in the ii0 folders if I find something obvious...

update May 22:

 

Solved. The error was caused by 2 things:

 

(see element14 question SAMA5D4 ADC driver - do you know a Linux image that has the driver?)

 

1. the source for generic_buffer.c : 

There's a multitude of versions of that file on the internet.
Here's the correct one: https://raw.githubusercontent.com/linux4sam/linux-at91/master/drivers/staging/iio/Documentation/generic_buffer.c

 

In the correct one, here's how the device is found:

 

 

dev_num = find_type_by_name(device_name, "iio:device");

 

In the wrong one:

 

dev_num = find_type_by_name(device_name, "device");

 

 

2. With the switch of the Yocto distro to device tree, the name of driver/trigger changed.

 

This is reflected on http://www.at91.com/linux4sam/bin/view/Linux4SAM/IioAdcDriver

 

echo "fc034000.adc-dev0-continuous" > /sys/bus/iio/devices/iio:device0/trigger/current_trigger
./generic_buffer -n fc034000.adc -t fc034000.adc-dev0-continuous -l 2
The result:

 

Maybe the image that I use (the HDMI demo that peteroakes also uses in his videos) may not have the driver for ADC loaded...

 

According to at91.com, the driver should be at /lib/modules/3.5.0/kernel/drivers/iio/adc/at91_adc.ko

My build is not 3.5.0, but 3.10.0-custom.

I get up to lib/modules/3.10.0-custom/kernel/drivers.

There is no iio in that folder.

 

 

I'l check if there's more info somewhere else...

In /sys/devices/ahb/ahb:apb/fc034000.adc/modalias , I found a reference to the driver name at91sam9x5-adc

But I couldn't load the driver and the generic_buffer tool failed to find that driver too.

 

I've also downloaded nd installed the latet Poky image available from Sama5d4XplainedMainPage < Linux4SAM < TWiki

I've done a file find for all .ko files (I'm searching where the adc_91 would b).

 

find . -print | grep -i '.*[.]ko' > ~/drivers.log

 

The results are attached to the blog (drivers.log). I couldn't find the adc driver.

Attachments:
drivers.log.zip
Anonymous
Parents
  • Jan Cumps
    Jan Cumps over 7 years ago

    I've updated the post now that I have it working.

    If you want to check out how I got everything up, check SAMA5D4 ADC driver - do you know a Linux image that has the driver?

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
Comment
  • Jan Cumps
    Jan Cumps over 7 years ago

    I've updated the post now that I have it working.

    If you want to check out how I got everything up, check SAMA5D4 ADC driver - do you know a Linux image that has the driver?

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
Children
No Data
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube