LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-23-2016, 04:47 AM   #1
prophEt666
LQ Newbie
 
Registered: Jul 2015
Location: Austria
Posts: 6

Rep: Reputation: Disabled
BSP porting Question from 2.6.17 to 2.6.39


Hi,

The hardware forum is probably better suited for my question than the software forum.


My current task is to port a working non-mainline Board Support Package based on an ARM CPU (Embedded System) from the kernel 2.6.17 to 2.6.39. Do you have any documentation available which can help me achieving that task as there were major kernel changes regarding BSPs?

As of now, the init routines for the machine, IRQs and timer seem to work (or at least don't result in a kernel panic, debugged via JTAG), but I am not able to get the UART running (8250serial). I'm smelling issues with virtual/physical memory... Does anyone have experience in this regard and give me some hints?

Thanks in advance.
 
Old 09-23-2016, 05:37 PM   #2
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by prophEt666 View Post
My current task is to port a working non-mainline Board Support Package based on an ARM CPU (Embedded System) from the kernel 2.6.17 to 2.6.39.
The first thing I would do is create a patch file of all differences between mainline and the custom kernel.
Those changes (probably) need to be ported, as a new patch file for the 2.6.39 mainline kernel.

For each custom code module (that didn't exist in mainline), e.g. the board file and device drivers, I would look for the most similar file in mainline 2.6.17 to provide a baseline. The evolution of such a file from 2.6.17 to 2.6.39 is the guide for updating the custom module.

Other than the release notes for each kernel version, you're not going to find a guide for all the changes in internal kernel interfaces.

Quote:
Originally Posted by prophEt666 View Post
...but I am not able to get the UART running (8250serial). I'm smelling issues with virtual/physical memory.
In the Linux kernel the only intersection of physical and virtual memory is in the MMU and DMA.
If you suspect DMA issues, then switch to PIO mode as a test.

Regards

Last edited by blue_z; 09-23-2016 at 05:42 PM.
 
Old 09-24-2016, 08:14 AM   #3
prophEt666
LQ Newbie
 
Registered: Jul 2015
Location: Austria
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thank you for your ideas.

Quote:
Originally Posted by blue_z View Post
The first thing I would do is create a patch file of all differences between mainline and the custom kernel.
According to the patch file, the only differences are the BSP I have to port (the arm/mach folder) and a few drivers. As the 2.6.17 kernel was built using cygwin, a few makefiles also differ. In 2.6.17 the include directory for a BSP (containing hardware.h, memory.h, ...) was not part of the arch/mach folder, but that should not be of a problem.

I have compared the BSPs of 2.6.17/2.6.39 from other machines/architectures (like OMAP1/2). There were major changes regarding hardware timers (the concepts of clockevents/clocksources have been introduced in the meantime). To be honest, I do not yet completely understand those "new" concepts. Do I have to adapt them or will the old way (configuring hw timer, setting up IRQ, timer_tick for kernel, ...) without clockevents/sources work too?

Quote:
Originally Posted by blue_z View Post
In the Linux kernel the only intersection of physical and virtual memory is in the MMU and DMA.
As far as I have seen, the original BSP does not contain any DMA code. I probably have to integrate that piece at a later stage (primarily for eMMC performance) when the kernel is successfully booting. The support of newer eMMC cards is the main reason for switching to the newer kernel. Which leaves the MMU as a possible source of issues.

I have tried to enable KERNEL_DEBUG_LL and EARLY_PRINTK in the hopes of getting UART output, but I haven't had any luck so far. The asm macro "addruart" ((contained in mach/debug_macro.S) which is responsible for DEBUG_LL output) did get a new parameter added between 2.6.17 and 2.6.39 as the check for active MMU has been moved to debug.S in the kernel. As far as I understand, the first parameter stores the physical, the second one the virtual address. So hardcoding those UART addresses within the asm macro should suffice for a test. The other macros senduart, waituart, buyuart should be the same as in the original kernel. Nevertheless, I don't see any output yet. I assume that the calculation physical address to virtual address stays the same between kernels as this should be a CPU specific thing?

Best regards
 
Old 09-24-2016, 03:35 PM   #4
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by prophEt666 View Post
According to the patch file, the only differences are the BSP I have to port (the arm/mach folder) and a few drivers.
(Real kernel developers don't use GUI terms like "folders" in place of proper filesystem terms.)
What is this mystery BSP?
Is this for a proprietary board design, or a board based on a reference design, or is there a complete arch/arm/mach-xxx directory that's not in mainline?

Regards
 
Old 09-24-2016, 04:30 PM   #5
prophEt666
LQ Newbie
 
Registered: Jul 2015
Location: Austria
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by blue_z View Post
(Real kernel developers don't use GUI terms like "folders" in place of proper filesystem terms.)
Hehe, well I originally was a Java developer. I switched to embedded systems after my studies because it's way cooler . So probably thats why I'm prone to mixing up terms. So, porting BSPs between different kernels is kinda new to me as you can tell.

Quote:
Originally Posted by blue_z View Post
Is this for a proprietary board design ...
Yes, you have guessed it. Also, the CPU is an old ARM922T(v4t) which is not produced anymore. My task is to do some performance optimizations for the existing design.

Best regards.
 
Old 09-24-2016, 06:39 PM   #6
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by prophEt666 View Post
>Is this for a proprietary board design ...
Yes, you have guessed it. Also, the CPU is an old ARM922T(v4t) which is not produced anymore.
That's not the information I'm looking for.
Is this processor in an SoC?
And isn't there already an arch/arm/mach-xxx directory in mainline, and that this BSP provides a board file plus header files?
Did you customize the BSP board file?


Quote:
Originally Posted by prophEt666 View Post
Which leaves the MMU as a possible source of issues.
You're trying to catch the wind.
The ARM922T has been supported in the mainline Linux kernel.
You're probably using mainline code for all the processor and MMU functionality.
That's mature code, and you're using it in a conventional manner, so the likelihood of you encountering an "issue" is very remote.

Quote:
Originally Posted by prophEt666 View Post
There were major changes regarding hardware timers .... Do I have to adapt them .
Yes. Certainly before you start "debugging" and speculating where the issues are.
IIRC management of clock resources was introduced in early 2.6.2x, and UARTs need a clock source for the baudrate generator.


Regards

Last edited by blue_z; 09-24-2016 at 08:55 PM.
 
Old 09-25-2016, 05:35 AM   #7
prophEt666
LQ Newbie
 
Registered: Jul 2015
Location: Austria
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by blue_z View Post
Is this processor in an SoC?
And isn't there already an arch/arm/mach-xxx directory in mainline, and that this BSP provides a board file plus header files?
Did you customize the BSP board file?
The arch/arm/mach-xxx (in my understanding this is the BSP, excluding drivers, please correct me if I'm wrong) is only part of my customized 2.6.17. I moved the mach-xxx (with the board file/header files) from the customized 2.6.17 to 2.6.39. The BSP also contains code for IRQ handling, GPIOs and hardware timer support. There are 2 additional drivers associated with this machine: an SPI and MTD map driver.

I customized the Kconfig files for ARM to be able to build the BSP/the drivers for ARM922T like it was done in my custom 2.6.17. I also had to add the machine type into mach-types.h. After fixing a few minor syntax errors because of API changes, removed header files (like linux/config.h), ... the kernel built successfully for my machine. The basic boot process also "seems to work": map_io, init_irq, init_machine are all executed ("debugged" via JTAG).

Now I'm gradually looking at the various components of the BSP by comparing existing ARM architectures from 2.6.17 to 2.6.39 and how they have changed over time, so that I can adapt them for my machine if needed. The first thing I wanted to get working is the UART for obvious reasons.

Quote:
Originally Posted by blue_z View Post
The ARM922T has been supported in the mainline Linux kernel.
You're probably using mainline code for all the processor and MMU functionality.
Yes, there is no CPU-specific setup code in the BSP. Reading the CP15 registers via JTAG also revealed that the MMU is active.

Quote:
Originally Posted by blue_z View Post
IIRC management of clock resources was introduced in early 2.6.2x, and UARTs need a clock source for the baudrate generator.
Is this also true for EARLY_PRINTK? AFAIK, this functionality is realized by the ASM routines defined in debug.S (which includes debug_macro.S from the BSP). How is the baud rate generated in this case?

Thanks for the hint to integrate the clock source/events.

Best regards.
 
Old 09-26-2016, 02:02 PM   #8
prophEt666
LQ Newbie
 
Registered: Jul 2015
Location: Austria
Posts: 6

Original Poster
Rep: Reputation: Disabled
I finally managed to get the UART running and the 2.6.39 kernel booting on the embedded device. In the end, it was easier than expected. I did not know that EARLY_PRINTK has to be configured via the kernel boot parameters to use the UART. After I added the parameter and changed the addruart asm macro, I was able to see the boot messages.

Those messages revealed that both 8250 UART ports did not register successfully with the kernel (EINVAL was returned). After some debugging it was clear that the uartclk struct member of the ports contained a strange value. This value should have been the hclk of the device derived from the PLL register set by doing some calculations, so I was reading garbage from those registers. It turned out that I actually wasn't reading from the PLL register because during my port procedure the address got changed somehow (probably my own fault, anyways I checked the rest of the I/O addresses, they are all correct). After this got fixed the kernel bootet up successfully and I was able to interact with the shell via UART.

Best regards.
 
  


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
BSP porting guide from 2.6.17 to 2.6.39 prophEt666 Linux - Kernel 0 09-23-2016 10:00 PM
Porting question... japreja Programming 2 07-07-2010 02:08 PM
EP440XS board BSP question linuxwang Linux - Newbie 1 09-23-2009 01:33 PM
LXer: BSP Marathon / BSP in Berlin (Germany) September 22-24 LXer Syndicated Linux News 0 09-06-2006 07:54 PM
LXer: BSP Marathon / BSP in =?iso-8859-1?Q?ich?= (Germany) 15.-17. September LXer Syndicated Linux News 0 08-23-2006 08:54 PM

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

All times are GMT -5. The time now is 09:04 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