Forum Discussion
Altera_Forum
Honored Contributor
16 years agoLinux with MMU on NEEK
Hi, all.
I'm testing Linux MMU version, on my NEEK. http://www.nioswiki.com/linux It works fine and I can use "bash" shell. This is the evident proof that we are using the true 'fork' instead of 'vfork'. May be this will depends on the version, but TSE driver claims an error and doesn't work on this design. The error is
ERROR: altera_tse.c:1666: request_mem_region() failed
I think that this error is caused by misunderstanding of the usage for the function request_mem_region(). Inside of the request_mem_region(), the function __request_region() is called. If the resource has been already registered, this function returns a non-NULL value, that is the pointer for its resource. But the resource 'sgdma_rx_base' is already registered in the initialization process, so this function returns the 'conflict' and
if (!request_mem_region(sgdma_rx_base, sgdma_rx_size, "altera_tse")) {
is always true. So I made a dirty patch,
if (!request_mem_region(sgdma_rx_base, sgdma_rx_size, "altera_tse")) {
reg_resource = __request_region(&iomem_resource, sgdma_rx_base, sgdma_rx_size, "altera_tse", 0);
if (reg_resource != NULL && reg_resource->flags & IORESOURCE_BUSY) {
printk(KERN_ERR "ERROR: %s:%d: request_mem_region() failed\n", __FILE__, __LINE__);
ret = -EBUSY;
goto out_sgdma_rx;
}
}
Moreover, the author is forgetting that the DMA is working in the physical address world, so we need to set the pointers of descripters like
// desc->source = read_addr;
desc->source = virt_to_phys(read_addr);
// desc->destination = write_addr;
desc->destination = virt_to_phys(write_addr);
// desc->next = (unsigned int *)next;
desc->next = (unsigned int *)((unsigned long)next & 0x1fffffffUL);
and so on. Also the frame buffer fb0 will not work well, because the driver 'altfb.c' is not implemented for Linux with MMU version. So I put some codes for altfb_mmap(), like
/* We implement our own mmap to set MAY_SHARE and add the correct size */
static int altfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
{
unsigned long phys_addr, phys_size;
unsigned long addr;
unsigned long size = vma->vm_end - vma->vm_start;
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
// vma->vm_flags |= VM_MAYSHARE | VM_SHARED;
// vma->vm_start = info->screen_base;
// vma->vm_end = vma->vm_start + info->fix.smem_len;
/* check range */
if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
return -EINVAL;
if (offset + size > altfb_fix.smem_len)
return -EINVAL;
vma->vm_flags |= VM_IO | VM_RESERVED;
addr = vma->vm_start;
phys_addr = altfb_fix.smem_start + offset;
if ((offset + size) < altfb_fix.smem_len)
phys_size = size;
else
phys_size = altfb_fix.smem_len - offset;
vma->vm_page_prot = __pgprot(_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE);
if (remap_pfn_range(vma, addr, phys_addr >> PAGE_SHIFT, phys_size, vma->vm_page_prot))
return -EAGAIN;
return 0;
}
and rewrite the DMA descripters like
desc->next = (void *)virt_to_phys((desc + 1));
So now, I can evoke telnetd and control NEEK through ethernet, and use Nano-X on Linux MMU version, but can't enter ftp session, because 'getservbyname()' function will not work well. I don't know the directory that the souce of 'getservbyname()' is included. Would anyone please tell me where is it? Thank you, in advance.95 Replies
- Altera_Forum
Honored Contributor
Thank you very much. Your feedback is very helpful.
The getservbyname is of glibc nss/inet. Please follow this file to get the toolchain source, http://sopc.et.ntust.edu.tw/pub/gnutools/nios2gcc4/readme - Hippo - Altera_Forum
Honored Contributor
Maybe lib nss is missing,
Please try turn off trim libs with, Blackfin build options --> Cull unused ELF shared libraries --> no - Hippo - Altera_Forum
Honored Contributor
Hi,
Thank you, Hippo. By selecting 'Blackfin build options --> Cull unused ELF shared libraries --> no', I was able to add the libraries 'libnss***.so' to /lib. Now 'inetd' and 'ftpd' are working well. But it seems that 'getenv()' that is used in 'ts_calibrate', will not work well yet. I haven't found the cause out and understood whether this is generated by libraries or not. I have another question. In 'nios2-linux/linux-2.6/arch/nios2/mm/dma-noncoherent.c', the function 'dma_alloc_coherent()' uses a macro 'UNCAC_ADDR()'. This macro transfers the input address like
but, UNCAC_BASE is set# define UNCAC_ADDR(addr) ((addr) - PAGE_OFFSET + UNCAC_BASE)
in 'spaces.h'. Why? This memory space has a special meaning?# define UNCAC_BASE 0xa0000000 - Altera_Forum
Honored Contributor
I think the uncached mapping was strange.
I am reworking the UNCAC_ADDR in page.h, like, # define UNCAC_ADDR(addr) ((void *)((unsigned)(addr) | IO_REGION_BASE))# define CAC_ADDR(addr) ((void *)((unsigned)(addr) & ~IO_REGION_BASE | KERNEL_REGION_BASE)) Please also change the mmap in uClinux-dist/lib/tslib-1.0/tests/fbutils.c to shared_map. I will commit this later. - Hippo - Altera_Forum
Honored Contributor
Fixed altfb, it was a bug to use ioremap to map return of kzalloc for sgdma descriptor table. Please see the update in unstable-nios2mmu branch of linux-2.6.git of sopc server.
- Hippo - Altera_Forum
Honored Contributor
tslib worked after increase the number of tty in static device_table.txt.
Though getenv() is still a problem. - Hippo - Altera_Forum
Honored Contributor
Hi.
--- Quote Start --- Fixed altfb, it was a bug to use ioremap to map return of kzalloc for sgdma descriptor table. Please see the update in unstable-nios2mmu branch of linux-2.6.git of sopc server. --- Quote End --- Oh sorry, I forgot to commit on this. Clearly we don't need to remap 'desc1'. In my case, I only comment the code
out, and do 'flush_cache_all()' before the return. I will do git and check your code later. --- Quote Start --- Though getenv() is still a problem. - Hippo --- Quote End --- I think that this is only the shell problem. In 'hush' or 'bash', we need to export shell variables, like// desc1 = ioremap((unsigned long)desc1, ndesc_size);
. Now I'm tackling 'fltk' demo programs. They request 'libstdc++.so**', so I copied it, but will not run and say 'Segment fault'.(Segment? in Nios ?:)). I want to make 'core dump', but the kernel will not output those. Of course, I set 'ulimit -c unlimited'. Why? Thank you, in advance./> TSLIB_CONSOLEDEVICE=none /> export TSLIB_CONSOLEDEVICE - Altera_Forum
Honored Contributor
Hi.
--- Quote Start --- I want to make 'core dump', but the kernel will not output those. Of course, I set 'ulimit -c unlimited'. --- Quote End --- This was only the kernel configuration problem. In the 'menuconfig', [* ] Customize Kernel Settings (NEW)-> Exit->Exit-> General setup ---> [*] Enable ELF core dumps so, we can get the 'core dump' with 'ulimit -c unlimited'. By setting
we can get simple register's information. About 'fltk' demo program's 'Segmentation fault', it seems some bugs of libraries.:mad: Kazuecho 1 > /proc/sys/kernel/print-fatal-signals cat /proc/sys/kernel/print-fatal-signals 1 - Altera_Forum
Honored Contributor
I tried hello,clock,editor of fltk. They all got "SEGV". I noticed that the fltk libs were built static. I wondered if we should try to build them shared.
- Hippo - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- I tried hello,clock,editor of fltk. They all got "SEGV". I noticed that the fltk libs were built static. I wondered if we should try to build them shared. --- Quote End --- :confused: I think the 'editor' is using shared libraries.
Would you please try next command in your NEEK?nios2-wrs-linux-gnu-g++ -Os -Wall -Wunused -Wno-format-y2k -fno-exceptions -fno-strict-aliasing -L/home/kazuyasu/nios2-linux/uClinux-dist/user/microwin/nxlib/fltk-1.1.8rc3/../nxlib-0.45 -mhw-mul -mno-hw-mulx editor.o -o editor ../lib/libfltk_images.a ../lib/libfltk.a -L../lib -lfltk_png -lz -lfltk_jpeg -ldl -lm
Now, I'm trying to debug the dynamic linking process by using GDB. Kazu/lib/ld.so.1 --list ./editor