2
votes

I have a problem about porting kernel from old SH4 to new SH4. Please let me show the difference between them.

[Old SH4]
boot loader: redboot v2.0
kernel version: 2.4

[New SH4]
boot loader: u-boot v2009.03
kernel version: 2.6

In old SH4, a lot of source code is developed based on kernel 2.4, so porting kernel 2.4 to new SH4 looks easier than recompiling source codes in kernel 2.6. So I applied mkimage to the zImage which was developed for old SH4 as shown below.

mkimage -A sh -O linux -T kernel -C none -a 0x8c210000 -e 0x8c210000 -n 'Old kernel' -d zImage uImage

This image is loaded on new SH4 as shown below.

tftpboot 8c800000 uImage
cp.b $(fileaddr) a0100000 $(filesize)
bootm a0100000

However, booting stops after "Uncompressing Linux... Ok, booting the kernel" and hangs. I found that the infinite loop happens at the below lines on kernel/head.S, but I suppose these lines have no problem because kernel/head.S is not customized and it works on old SH4.

   !               Clear BSS area
   mov.l   3f, r1 ! __bss_start
   add     #4, r1
   mov.l   4f, r2 ! _end
   mov     #0, r0
9: cmp/hs r2, r1
   bf/s    9b     ! while (r1 &lt r2)
   mov.l  r0,@-r2

Thus, I guess this problem comes from environment difference between old and new SH4. In old SH4, I execute fconfig command and set variables as shown below.

Load Linux Kernel & File System: true
Linux Kernel Destination address: 0x8c210000
Linux Kernel Source address: 0x80140000
Linux Kernel Size: 0x100000
RAM disk Destination address: 0x8c360000
RAM disk Source address: 0x80140000
RAM disk Size: 0x400000
Modify Linux Kernel Parameter: true
Linux Kernel base address: 0x8c001000
Linux Kernel ENTRY address: 0x8c210000
Linux Kernel INITRD size: 0xc00000
Linux Kernel INITRD start address: 0x360000
Linux Kernel loader type: 1
Linux Kernel mount root read only: 1
Linux Kernel original root device: 0x100
Linux Kernel RAM disk flags: 0
Linux Kernel Enable Virtual Terminal Console: false

I think I can set these parameters on new SH4, though u-boot doesn't have fconfig command. But I couldn't find how to set the parameters Linux Kernel Source address and Linux kernel base address. Is this related to the hang problem? Or any advice about what I should check next will be helpful since I am new to Linux embedded system.

Thanks for your help.

[Edited]
Below infomation is added to show printenv result on u-boot.

bootcmd=icache on
bootm a0100000
bootdelay=2
baudrate=115200
netmask=255.255.255.0
ipaddr=192.168.1.2
serverip=192.168.1.1
gatewayip=0.0.0.0
bootargs=console=ttySC1,115200,N,8 mem=32M ether=8,0x1300,0,0,eth0 video=e1356fb:system:ms104sh4,display:crt,bpp:8,800x600@60
stdin=serial
stdout=serial
stderr=serial

1
if you have access to the preboot envirnoment, you can use the uboot setenv command to set those. See denx.de/wiki/view/DULG/UBootEnvVariablesJ-16 SDiZ
Are you sure it's an infinite loop? What are the register values? The code you posted is clearing RAM area. If the kernel load address is incorrect you could be erasing the memory location where the code is running. I had a similar problem though on the PowerPC platform. My problem turned out to be incorrect base addresses in the Linux config file.sessyargc.jp
To J-16 SDiZ: Thanks for your comment. First I thought I could set LINUX base & source address via u-boot environmental variable, but found no variables for them. Maybe I have to set them in a different way not in env variables.mura_no
To sessyargc.jp: Thanks for your comment. It could be true that the address running is zero cleared dut to bad base address because I leave it default setting. I think I have to check again how I can set base address in SH4.mura_no

1 Answers

1
votes

I've never worked with SH4, but this has helped me in the past: http://www.denx.de/wiki/view/DULG/LinuxPostMortemAnalysis