LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 02-06-2019, 09:34 AM   #1
mashman
LQ Newbie
 
Registered: Feb 2019
Posts: 4

Rep: Reputation: Disabled
Reading 0's from memory after mmap


Running on a Xilinx Zynq SOC with ARM Cortex. The application I am supporting communicates with the peripherals such as SPI via direct register access with dev/mem, mmap etc...rather than drivers. I know this is not the preferred way to control the peripherals but this is how it is done in the application. I am upgrading from an older Linux kernel V3.x to a later Linux kernel V4.x. When I run the new kernel the mmap operation succeeds but when I read the contents of any device registers I read all 0's. If I run the older kernel I read the expected non-zero values.
If I get to a u-boot prompt and use the md command to read the memory I can see that the register values are correct and non-zero, but if I boot to Linux I read all 0's.
I use the busybox devmem and I get the same zero results. Busybox also does an mmap so that makes sense. Any ideas why mmap/devmem would read 0's?
 
Old 02-07-2019, 05:36 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,286

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Kernel 3.x.x --> 4.x.x implies a compatibility break. The way to sort that is painful. You're in for a bit of compiling.
First, have a look at the ChangeLogs to see if you spot a change affecting this. If you can spot one, test it by compiling a kernel before the break, and after it, and test them. You can apply and remove patches with 'patch'(man patch), so you won't have to grab the whole source every time.

If you can't spot it from that, go to the last 3,x kernel, and the 1st 4.x release and test those. Then go forward or back accordingly, testing as you go.

Either way, you'll eventually come to the bit that affects you. Then grok the patch source, look for an option to skirt around it, or halt there. If you have a working kernel, I'd stop updating it, unless you see clear benefits. I wouldn't start patching kernel source with your own code if at all possible. That would be a maintainance nightmare. It's safer to backport drivers. When you have moved on, pity some poor bugger asked to tidy up your code!
 
1 members found this post helpful.
Old 02-07-2019, 07:25 AM   #3
mashman
LQ Newbie
 
Registered: Feb 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thank you for your reply. Interestingly I can use devmem to query some addresses, so it seems that the functionality is not broken. It's just when I try to use it to address the registers of some peripherals, e.g. IC2, SPI. Would that still be a kernel compatibility thing?

Quote:
Originally Posted by business_kid View Post
Kernel 3.x.x --> 4.x.x implies a compatibility break. The way to sort that is painful. You're in for a bit of compiling.
First, have a look at the ChangeLogs to see if you spot a change affecting this. If you can spot one, test it by compiling a kernel before the break, and after it, and test them. You can apply and remove patches with 'patch'(man patch), so you won't have to grab the whole source every time.

If you can't spot it from that, go to the last 3,x kernel, and the 1st 4.x release and test those. Then go forward or back accordingly, testing as you go.

Either way, you'll eventually come to the bit that affects you. Then grok the patch source, look for an option to skirt around it, or halt there. If you have a working kernel, I'd stop updating it, unless you see clear benefits. I wouldn't start patching kernel source with your own code if at all possible. That would be a maintainance nightmare. It's safer to backport drivers. When you have moved on, pity some poor bugger asked to tidy up your code!
 
Old 02-07-2019, 08:48 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
So you replaced the kernel, but not the OS? what about libc.so ? Probably you need to rebuild your app (if that possible).
 
Old 02-07-2019, 09:11 AM   #5
mashman
LQ Newbie
 
Registered: Feb 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
So you replaced the kernel, but not the OS? what about libc.so ? Probably you need to rebuild your app (if that possible).
Thank you for the reply, the OS has been replaced as well as all libraries. The application is running well except for the ability to read from these device registers after mmap.
 
Old 02-07-2019, 09:28 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
I still think you need to recompile that app (if possible). From the other hand you may try to use strace to get more info.
 
Old 02-07-2019, 10:33 AM   #7
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,286

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Quote:
Originally Posted by mashman View Post
Thank you for your reply. Interestingly I can use devmem to query some addresses, so it seems that the functionality is not broken. It's just when I try to use it to address the registers of some peripherals, e.g. IC2, SPI. Would that still be a kernel compatibility thing?
It depends on if what's malfunctioning matters. If changing up the kernel and nothing else caused it, yes it's a kernel compatibility thing. The procedure to follow is in post #2.
 
1 members found this post helpful.
Old 02-22-2019, 09:01 AM   #8
mashman
LQ Newbie
 
Registered: Feb 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
The Linux Runtime Power Management was causing my problem. I disable that and I can communicate with the SPI. Linux was putting the device into a suspended state.
It looks like the power management was added or enhanced in kernel 3.10 so that makes sense.
Thank you
Quote:
Originally Posted by business_kid View Post
Kernel 3.x.x --> 4.x.x implies a compatibility break. The way to sort that is painful. You're in for a bit of compiling.
First, have a look at the ChangeLogs to see if you spot a change affecting this. If you can spot one, test it by compiling a kernel before the break, and after it, and test them. You can apply and remove patches with 'patch'(man patch), so you won't have to grab the whole source every time.

If you can't spot it from that, go to the last 3,x kernel, and the 1st 4.x release and test those. Then go forward or back accordingly, testing as you go.

Either way, you'll eventually come to the bit that affects you. Then grok the patch source, look for an option to skirt around it, or halt there. If you have a working kernel, I'd stop updating it, unless you see clear benefits. I wouldn't start patching kernel source with your own code if at all possible. That would be a maintainance nightmare. It's safer to backport drivers. When you have moved on, pity some poor bugger asked to tidy up your code!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
minor page faults in access mmap memory after msync jsyzghan Linux - Kernel 0 09-21-2014 03:46 AM
[SOLVED] Virtual Memory limit exhausted at 1TB? malloc/mmap failures even with free memory mfkraft Linux - Server 2 09-16-2012 08:27 AM
Question on using mmap to access physical memory Gnu2Linux2 Linux - Embedded & Single-board computer 1 10-05-2009 03:54 AM
Help needed: mmap and physical memory access manaav Linux - Newbie 3 03-25-2009 03:38 AM
How to lock/unlock the shared memory created by mmap? john.daker Programming 6 11-19-2008 09:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 09:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration