1/1

|
need help with linux boot using orpsocv2 rtl
by jason_rothfuss on Mar 5, 2010 |
jason_rothfuss
Posts: 10 Joined: Feb 25, 2010 Last seen: Jun 2, 2011 |
||
|
Hi,
I have successfully built the or32-elf toolchain, or1ksim, and the linux-2.6.24 kernel. I have verified that the or1ksim architectural simulator is working with my linux kernel by doing:
or32-elf-sim -f or1ksim_linux.cfg vmlinux
I have also been able to verify that my RTL compiles and simulates properly on ModelSim by doing:
$ cd sim/run
What I would like to do next is boot the linux kernel in RTL simulation. To give it a go, I tried creating the flash and sram images below, and firing up the simulation.
$ ../../sw/utils/bin2hex vmlinux.bin 1 -size_word > flash.in
This did not work for me. I assume that my code is is not correct at 0x100? If anyone could steer me in the right direction, I would appreciate it! Thanks! Jason |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by julius on Mar 5, 2010 |
julius
Posts: 323 Joined: Jul 1, 2008 Last seen: Feb 8, 2012 |
||
|
It's working for me. I don't know how far it goes into booting Linux (it takes a long time for it to full boot, many many hours) but I can see in the execution log that it's configured the MMU and performing intialisation of some kind.
Check the configuration of the compiled Linux kernel. I believe by default the "Boot from FLASH" option is enabled, as well as a frequency for the simulator of 100MHz, while ORPSoC is at 25MHz. In the kernel's menuconfig screen, under "Processor type and features", uncheck "Boot from FLASH". You can also set the expected clock rate in the same screen (change it from 100 to 25MHz under "System clock frequency [MHz]".) Everything else should be OK, except for perhaps if data cache is enabled (I think it's disabled in ORPSoC by default.) Recompile and try re-running like that. You could, if you wanted, actually perform the boot from FLASH in the simulator, but I would advise against it (and is the whole reason ORPSoC defaults to internal RAM magically preloaded with the application) because it would take a while to load the 3.6MBytes of kernel from FLASH into the SDRAM and execute. This is what the USE_SDRAM option in ORPSoC enables. The "Boot from FLASH" option in the kernel enables some code, being executed from FLASH, to copy itself into some memory elsewhere and then jump resume execution from there. Hence it breaks when it thinks it's in FLASH and wants to copy itself elsewhere. I'd stick to the internal SRAM, and in that case you only need to provide the sram.vmem file for ORPSoC (don't worry about the flash.in file). |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by jason_rothfuss on Mar 5, 2010 |
jason_rothfuss
Posts: 10 Joined: Feb 25, 2010 Last seen: Jun 2, 2011 |
||
|
Hi Julius,
Thanks for the quick response. I recompiled the linux kernel to disable boot from flash, and changed the clock frequency to 25 MHz. I recompiled the RTL with +define+USE_SDRAM, and I'm re-running my RTL simulation now. Just to make sure I have the correct expectation, I'm expecting to see console messages from booting linux (like we see using or1ksim) coming from the UART. Is this what you see in your working RTL simulation? Regards, Jason |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by jason_rothfuss on Mar 7, 2010 |
jason_rothfuss
Posts: 10 Joined: Feb 25, 2010 Last seen: Jun 2, 2011 |
||
|
A couple questions:
1. When I ran all sim-tests and rtl-tests, the sim tests are run using the or1ksim-orpsocv2.cfg file. This file differs significantly from the or1ksim_linux.cfg file that I had used to simulate booting linux. Since my rtl-tests matched the sim-tests results, I am wondering if I need to build a linux kernel that works with the or1ksim-orpsocv2.cfg file? Any info on this would be much appreciated. 2. Is there any documentation on how to sync up RTL defines with or1ksim cfg settings? Thanks! Jason |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by julius on Mar 8, 2010 |
julius
Posts: 323 Joined: Jul 1, 2008 Last seen: Feb 8, 2012 |
||
|
I recompiled the RTL with +define+USE_SDRAM, and I'm re-running my RTL simulation now.
There's two ways the system can boot in ORPSoCv2. One is from the large "internal" SRAM that gets preloaded with the sram.vmem file (default) or from FLASH (which is preloaded with the program), which copies the program into SDRAM and then executes from it. There's no way to immediately preload the SDRAM, which is probably what you want to do as simulating the copying of the app via SPI from FLASH isn't the most interesting thing. So I would recommend just using the internal SRAM memory as your memory model, to speed up simulation (although it would skew your performance specs, if that's what your interested in, because the internal SRAM takes less cycles to access)
Just to make sure I have the correct expectation, I'm expecting to see console messages from booting linux (like we see using or1ksim) coming from the UART. Is this what you see in your working RTL simulation?
Yes you should see the UART printout if everything is working correctly. In order for the UART decoder to be included in the simulation you need to define UART_PRINTF for the testbench.
I am wondering if I need to build a linux kernel that works with the or1ksim-orpsocv2.cfg file? Any info on this would be much appreciated.
There does appear to be several differences between those files, but mainly I think it's just the clock rate and locations of memory. The config file included with Linux sets up a FLASH memory at 0xf0000000, whereas in ORPSoC there isn't a directly addressable FLASH memory server, (it's used via an SPI controller, and is a little more involved than just requesting an address to read from) so the config file reflects this, although there does appear to be a FLASH memory section defined from 0x04000000, but that isn't used by the software. None of the other peripherals really matter (most are not implemented in ORPSoCv2). So, I think to make a Linux image that boots in ORPSoCv2's RTL model you just need to change the frequency, and disable the boot from FLASH option. The RTL and testbench should be configured so it's loaded into the internal SRAM model, and then enable UART output. Potentially the kernel tries to initialise the ethernet MAC core at some stage, so maybe you want to run the model with that enabled too. One of the things I did get running a while back was Linux in the cycle-accurate model. I remember I got that to boot, so unless you have a fast simulator, I'd recommend using that by just doing a 'make prepare-vlt' (or 'make prepare-vlt-profiled' if you have a few extra minutes) and then you can even just load the vmlinux elf directly into the simulator that way I think. |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by julius on Mar 8, 2010 |
julius
Posts: 323 Joined: Jul 1, 2008 Last seen: Feb 8, 2012 |
||
|
I recompiled the RTL with +define+USE_SDRAM, and I'm re-running my RTL simulation now.
There's two ways the system can boot in ORPSoCv2. One is from the large "internal" SRAM that gets preloaded with the sram.vmem file (default) or from FLASH (which is preloaded with the program), which copies the program into SDRAM and then executes from it. There's no way to immediately preload the SDRAM, which is probably what you want to do as simulating the copying of the app via SPI from FLASH isn't the most interesting thing. So I would recommend just using the internal SRAM memory as your memory model, to speed up simulation (although it would skew your performance specs, if that's what your interested in, because the internal SRAM takes less cycles to access)
Just to make sure I have the correct expectation, I'm expecting to see console messages from booting linux (like we see using or1ksim) coming from the UART. Is this what you see in your working RTL simulation?
Yes you should see the UART printout if everything is working correctly. In order for the UART decoder to be included in the simulation you need to define UART_PRINTF for the testbench.
I am wondering if I need to build a linux kernel that works with the or1ksim-orpsocv2.cfg file? Any info on this would be much appreciated.
There does appear to be several differences between those files, but mainly I think it's just the clock rate and locations of memory. The config file included with Linux sets up a FLASH memory at 0xf0000000, whereas in ORPSoC there isn't a directly addressable FLASH memory server, (it's used via an SPI controller, and is a little more involved than just requesting an address to read from) so the config file reflects this, although there does appear to be a FLASH memory section defined from 0x04000000, but that isn't used by the software. None of the other peripherals really matter (most are not implemented in ORPSoCv2). So, I think to make a Linux image that boots in ORPSoCv2's RTL model you just need to change the frequency, and disable the boot from FLASH option. The RTL and testbench should be configured so it's loaded into the internal SRAM model, and then enable UART output. Potentially the kernel tries to initialise the ethernet MAC core at some stage, so maybe you want to run the model with that enabled too. One of the things I did get running a while back was Linux in the cycle-accurate model. I remember I got that to boot, so unless you have a fast simulator, I'd recommend using that by just doing a 'make prepare-vlt' (or 'make prepare-vlt-profiled' if you have a few extra minutes) and then you can even just load the vmlinux elf directly into the simulator that way I think. |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by jason_rothfuss on Mar 9, 2010 |
jason_rothfuss
Posts: 10 Joined: Feb 25, 2010 Last seen: Jun 2, 2011 |
||
|
Thanks for the info, Julius. I tried the cycle-accurate simulation, but still can't boot this kernel. See below:
However, the uart-nocache.or32 test does pass and match rtl-simulation. Also, 18/18 vlt-tests pass.I am guessing that this means that my vmlinux is bad? If possible, can someone post a working .config to allow booting linux in rtl or sysc simulation? Any advice on debugging this problem is welcome. Thanks! Jason |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by julius on Mar 9, 2010 |
julius
Posts: 323 Joined: Jul 1, 2008 Last seen: Feb 8, 2012 |
||
|
The config I'm using should be the same as this the one on the Linux and BusyBox guide: http://opencores.org/openrisc,linux_busybox
I've compiled that and are now running it in the simulation, but have spotted an error:
Runarunaround: Unhandled exception 0x200: EPC=0x4874
Runarunaround: Unhandled exception 0x200: EPC=0x264 The problem is to do with a simple thing very early on (in the first few functions it calls) it tries to convert the address of the little "Ok, booting" string from a virtual to physical address, passing it through a function called tophys() which subtracts the Linux kernel's virtual address base (0xc0000000), however this address is already a physical address, so we end up with an invalid address, which gets put out on the bus, which of course doesn't know what to do and errors, or something like that, so it then goes to 0x200, a bus error. If I disable that tophys() there (just copy the value instead) I then see a couple more calls which trip up the boot process. Not sure if'll you'll see these problems, but I encountered them here, so I thought it'd note it. |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by julius on Mar 9, 2010 |
julius
Posts: 323 Joined: Jul 1, 2008 Last seen: Feb 8, 2012 |
||
|
I had to disable a few tophys() calls in both the reset vector and the _start function in arch/or32/kernel/head.S, and it looked like it booted and ran for a while.
I launched the cycle accurate model like so:
user@host:~/Documents/orpsocv2/sim/run$ ../vlt/Vorpsoc_top -f vmlinux --log-noregs -b exlog
And then monitored where it was by doing this in another open console:
tail -c 33 exlog | hexdump -C
This isn't pretty, but it's quick and easy, you'll get this output:
user@host:~/Documents/orpsocv2/sim/run$ tail -c 33 exlog | hexdump -C
ee c4 00 00 00 00 00 c8 55 13 00 fa ff ff 13 00 2f ee c4 00 00 00 00 00 cc 55 13 00 01 00 84 b8 00 (I stripped the little address and ascii decoding from either side of the data to avoid confusion.) The line you want to look at is the middle one (at least this seemed to be where tail got its data from each time). Essentially when you do a binary log in the cycle accurate model, with no register data, it dumps out 8 bytes of instruction counter, then 4 byte PC and 4 byte instruction, and 1 byte indicating whether it's an exception or not, so 25 bytes in all. The bytes are printed LSB first, so they're backwards as you read them from hexdump. But here, reading that middle line we can tell we're at instruction number 12,906,031 (or 0xc4ee2f), the PC is 0x001355cc, and the instruction is 0xb8840001 (verified by doing a or32-elf-objdump -d vmlinux | grep 1355cc). The reason i monitor the simulation this way is because when the sim is running and creating a human-readable log (without the -b option) it's slower. Also, if you disable the dumping of the GPR values that speeds it up too. Of course you can always connect GDB via RSP to control it that way too, but here I was just trying to see if the thing was working. And it looks like it it's doing something other than crashing. Although, if I ran it for a while I noticed it went to the kernel panic function, which I guess is not a good thing. But, I guess to debug that you would connect GDB and run it and set a break there, and see how it ended up going there. An aside: to convert those binary logs back to humanreadable form there's a tool I wrote in sw/utils called binlog2readable - it lets dump all or part of the binary log to see what it was doing. |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by jason_rothfuss on Mar 22, 2010 |
jason_rothfuss
Posts: 10 Joined: Feb 25, 2010 Last seen: Jun 2, 2011 |
||
|
I'm getting different results. The sim starts up at the reset vector 0x100, jumps to 0x223c, runs a few instructions, then a bus error occurs.
One thing I noticed is that the _tng_start_kernel symbol (which I believe is supposed to be the reset vector) is at address 0x00009c00. This doesn't seem right to me. If I look at the uart-nocache.or32 symbols, I see that the reset vector is mapped to 0x100 and all other exceptions are mapped properly. Is there something wrong with the linker script for the linux kernel? Thanks, Jason |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by jason_rothfuss on Mar 23, 2010 |
jason_rothfuss
Posts: 10 Joined: Feb 25, 2010 Last seen: Jun 2, 2011 |
||
|
I see now that the reset vector is in arch/or32/kernel/head.S. I mistakenly thought it was in arch/or32/kernel/entry.S.
The kernel starts booting (then fails with a bus error) in the SystemC model when I unset the CONFIG_OR32_MC_INIT parameter in the .config file. |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by julius on Mar 23, 2010 |
julius
Posts: 323 Joined: Jul 1, 2008 Last seen: Feb 8, 2012 |
||
|
I saw this error before.
For me it was caused by those tophys() functions being called on an address that wasn't in the virtual address space. I removed the calls to tophys() which were being passed linker-defined constants. Here are a couple of examples of what I did in head.S: /* * set up initial ksp and current */ LOAD_SYMBOL_2_GPR(r1,_init_thread_union+0x2000) // setup kernel stack LOAD_SYMBOL_2_GPR(r10,_init_thread_union) // setup current /* tophys (r31,r10) -- jb*/ l.and r31, r10, r10 l.sw TI_KSP(r31), r1 clear_bss: LOAD_SYMBOL_2_GPR(r24, ___bss_start) LOAD_SYMBOL_2_GPR(r26, __end) /*tophys(r28,r24) tophys(r30,r26) --jb*/ l.and r28, r24, r24 l.and r30, r26, r26 LOAD_SYMBOL_2_GPR(r4,_string_ic_enable) /*tophys (r3,r4) --jb*/ and r3, r4, r4 In fact, those were the 3 places where it was getting caught while booting, perhaps there's more later. I don't know the elegant way of fixing it - I think most of the things it's converting from the 0xc0000000 address space are values which the linker script ultimately controls. You can try just making tophys() not do the actual subtraction of 0xc0000000 from the value (function is in include/or32-asm/or32_asm.h) but that may break things. |
|||
|
RE: need help with linux boot using orpsocv2 rtl
by jason_rothfuss on Apr 12, 2010 |
jason_rothfuss
Posts: 10 Joined: Feb 25, 2010 Last seen: Jun 2, 2011 |
||
|
I wiped out my kernel build with the tophys() changes and started from scratch. I untarred the linux kernel, applied the or32 patch. I then did "make menuconfig" and disabled "Boot From Flash", "Initialize Memory Controller", and changed the CPU clock speed to 25MHz. For whatever reason, now things are *much* better. The SystemC model is now matching the RTL model. I am able to boot up to the following place, but then get the same error (shown below) in RTL and SystemC. Any ideas where to look to fix this issue? I feel like I'm really close now...
|
|||
1/1

