Jun 28 1999 |
Set up SH3 low cost evaluation board at home. Played with Hitachi
provided software (Hitachi Debug Interface - Windows GUI debugger)
and Windows versions of GNU tools from Cygnus compiled with Cygwin32.
Realised that the boards are provided with a new version of the monitor which doesn't have a text interface, only a binary command interface driver by the Windows program. Bugger. |
Jun 29 | Set up a second PC running a serial port monitor to capture traffic between the host PC running the HDI software and the target. Protocol is certainly binary. |
Jun 30 | Started marking some headway with the protocol. Understand general packet structure, checksum and some commands and responses. Started writing sh3mon tool to allow a program to be booted from a Linux command line. Still can't get the same results as Monitor though. |
Jul 1 | Finally booted some simple code from Linux. The Linux serial port was still configured to do LF->CR mapping (fool!). |
Jul 3/4 1999 |
Built versions of gcc and binutils for SH with Linux host. Modify
sh3mon to parse ELF executable (using BFD) and load this. Rebuilt
LED flashing example with these tools and it boots! We have a
development system!
Stated work on getting SH3 serial port running. Polled example runs pretty soon, interrupt driven version takes a little longer, my SH3 assembler is a little shaky. |
Jul 5 1999 |
Created CVS repository, importing gcc 2.7.2.3, binutils 2.9.1 and
Linux kernel 2.2.9. Also imported the sh3mon sources and the
examples for LED flashing and using the serial port.
Started web page. Instructions for retrieving src from repository and building GNU tools. Hacked sleeping Penguin logo together. |
Jul 6 1999 | Started trying to get Linux kernel to build. Created config.in with minimal contents, generate a .config.h with everything undefined. Try and build, loads of missing header files. Started filling in files in include/arch-sh from whichever architecture looks most useful (usually the smallest ones!). Modify anything obvious for SH. Any inline functions or macros which I don't know what to do about (most of them!) I replace with calls to functions which will be undefined so it will be obvious at link and then run time. |
Jul 7 1999 |
Still more header files.
Realised that I've built the sh-*-elf GNU tools, and so no Linux macros will be set up automatically. Add support for sh-*-linux to binutils and gcc. |
Jul 10/11 1999 |
Finished with the header files. Supplied dummy versions of arch/sh/kernel/head.S
and arch/sh/mm/dummymm.c, and copied in a arch/sh/vmlinux.lds.
Build now completes. Link fails with 110
undefined functions. Generated a dummy file containing definitions
of these functions and link completes. A 200K kernel, not too bad I
suppose.
Try and boot kernel, and it fails to boot. Must be a problem with sh3mon, but what? Suddenly realise that the ROM monitor exception handlers will still be active. My code is booting quite happily, just generating an exception as soon as it runs. Screw up in BSS initialisation. Code now reaches my first dummied function, setup_arch(), and dies there. |
Jul 12 1999 | Tried to get serial port working. It doesn't. Finally tracked down to a bug in BFD. The addend in relocations is not being added in when a relocation is applied, and all partial links result in the addend being adjusted. Found a comment in BFD saying the COFF version doesn't do this, so the ELF one won't either, even though it is wrong. Fix this, and the serial port bursts into life. The first kprintf from Linux/SH: "Calibrating delay loop... ". |
Jul 13 1999 | Checked in changes to CVS so that the others can start working on this thing. |
Jul 17/18 1999 |
More work in binutils and gcc:
|
Jul 20 1999 |
Got fed up with endianness problems, flipped default endianness to little
for sh-*-linux tools.
Checked in the latest set of changes. Everything now builds on Solaris as well as Linux host. |
Jul 22 1999 |
Sorted out some of the problems which were preventing the early stages
of memory initialisation running. Now dies while calibrating delay
loop because there no timer.
Shifted address space of kernel so that it now runs from kernel memory (P1 area). This will allow the kernel to be mapped without needed TLB entries, however it ties the kernel address space to physical memory, so I'm not sure if this is a good idea. |
Jul 24 1999 | Re-wrote exception and interrupt handling code so that all registers are now correctly saved and restored onto the supervisor stack. Implemented basic interrupt handling code, and a simple timer module so that kernel ticks now work. We now have a BogoMIP figure, 6.44! |
Jul 26 1999 |
Started work on the next block of memory initialisation, mem_init.
Although this is pretty simple, it also resulted in whole load of machine
specific functions being called for the first time atomic_...
and test_and_set_bit etc. These have now been implemented, some
directly in asm, some still by calling cli. Not sure the asm
version actually wins much on the SH.
Also spotted that in_interrupt was always returning true. Turned out some of the dummy `functions' were the data structures used to keep track of interrupt nesting level. Fixed this, and promptly broke the tick code, which hadn't been doing anything useful before. Tracked this down to current still being 0. Copied in the init_task_union, fixed the CPU specific macros which initialises this, initialise current, the initial stack pointer, and it works again. Also turned the cache on. Now get 29.9 BogoMIPs. That's more like it! |
Jul 29 1999 | Fixed the semaphore code. No attempt to implement an architecture specific version, just call atomic_... functions at the moment. This appears to work well enough for some other architectures though. |
Jul 29 1999 | Started working on the code for context switches. Implemented simple version of kernel_thread, which traps to sys_clone. Major change to the exception handling code to allow different exceptions to be be vectored to different handlers. This allowed a trapa handler to be implemented, which uses another table to jump to the appropriate handler. |
Jul 30 1999 |
Having started working on context switch code yesterday, and done nothing
but set up infrastructure, finally started working on the real
context switch code. Implemented copy_thread, completed
kernel_thread and started on _switch_to. Also introduced
the auto generation of sh_defs.h for constants needed in asm.
Obviously, this didn't work immediately, and was hard to debug, so I added a bunch of functions to support tracing into memory, and dumping the contents on the next reboot. Hasn't helped get context switching working yet. |
Aug 1 1999 |
Fixed some stupid mismatches between _switch_to and
copy_thread, and context switches burst into life. We now
have four kernel tasks being created and things now fall over trying
to mount the root file system.
Just for the record, this is what the start up sequence now looks like: Linux version 2.2.9 (stuart@jaguar) (gcc version 2.7.2.3) #63 Mon Aug 2 10:51:11 BST 1999 Trace buffer: 880f8000 : 12345678 880f8010 00000000 00000000 xV4............. start of paging_init (88058f10 -> 880f8000) before free_area_init In trap_init In time_init request_irq: code 1024, irq 18, flags 0 Calibrating delay loop... 29.90 BogoMIPS Memory: 624k/992k available (220k kernel code, 100k data, 0k init) POSIX conformance testing by UNIFIX kernel_thread(88003900, 0, e00) copy_thread: p 880f6000, old sp 88041fdc, new sp 88041fdc (unimplemented fn "do_check_pgt_cache" called) in idle! Linux NET4.0 for Linux 2.2 Based upon Swansea University Computer Society NET3.039 kernel_thread(8801b488, 0, e00) copy_thread: p 880f4000, old sp 88041fb8, new sp 88041fb8 Starting kswapd v 1.1.1.1 kernel_thread(8801168c, 0, e00) copy_thread: p 880f2000, old sp 88041fb8, new sp 88041fb8 kernel_thread(88014c84, 0, e00) copy_thread: p 880f0000, old sp 88041fb8, new sp 88041fb8 (unimplemented fn "do_gettimeofday" called) VFS: Cannot open root device 00:00 Kernel panic: VFS: Unable to mount root fs on 00:00 |
Aug 2 1999 |
Needed a root file system for the start up code to mount. With no
physical device to load it from it has to be part of the boot image.
Decided that the ROM FS looked the most useful, but this still needs
a block device to reside on. Started digging and found the ideal
solution, a
ROM block device. Integrated this into the build, and the root FS
now mounts! System now falls over when it fails to exec init.
Fixed a problem in the copy_thread code, which got the initial stack wrong for kernel threads. Next wrote a file onto the root FS and tried to open and read it. This highlighted a number of problems:
Next step is to try and get the exec of init working. |
Aug 3 1999 | Added code to support the CONFIG_HEARTBEAT option on the EVB7708. Started working on the exec code. Implemented sys_execve, built a noddy init and started debugging what went wrong. A slew of unimplemented functions got called, including some cache and MMU related ones. |
Aug 4-8 1999 |
Started working out how to implement the missing MMU related
functions. Most turned out to be things which have to be defined in
pgtable.h, as well as the obvious TLB miss handler, and
some support functions for allocating and freeing page tables.
Got bogged down trying to understand how we could handle system with multiple banks of memory. As long as all the initialisation can be performed in the first bank, it should be possible by simply making __pa and __va search lists rather than perform simple bit twiddling. RISC-PC appears to be the only other system which supports this kind of thing. Otherwise we start having to map kernel pages via the MMU, which I'm trying to avoid. Turned the MMU on, and promptly got a fault from kernel code! This turned up a couple of problems; a silly bug in the interrupt handler, and the LED flashing code was accessing the memory mapped register using user space not kernel space addresses. Fixed these, and now back to falling over in the exec of init. |
Aug 9-15 1999 | Went to see the eclipse. |
Aug 16 1999 | Took a break from the MMU code, and implemented booting of compressed kernel images. Turned out to be very simple, although it adds yet more locations where physical memory layout is known about. Major benefit as far as I'm concerned is that it reduces kernel boot time from around 70 seconds to 40. |
Aug 17-19 1999 | Finally started implementing the MMU related code. Page tables are being constructed, and their contents look reasonable. However when the kernel attempted to load init into memory, it doesn't, and exec() simply returns with an error code. Started littering the ELF loader code with debugging prints, and found a number of problems with my constant definitions in elf.h. Still don't have my code in memory though when trying to execute it. |
Aug 20 1999 |
Another diversion into SH4 work. Went through the code adding SH4 support
where required. Most is #ifdef CONFIG_SH4 at the moment. Gave
some thought to producing kernels which would boot on both SH3 and SH4, and
determine which they are running on at run-time, but decided it was
probably not useful for the embedded version, although the H/PC users
may be interested. However for now I'll live with the conditional
compilation.
SH4 version now gets as far as the SH3 version did before I started MMU work. |
Aug 22 1999 | Finally tracked down the ELF loading problems. Turns out when mapping each section of the executable it was calling ISREG, which boils down to (mode & 0xf000) == 0x8000, where mode is an unsigned short. Using gcc 2.7.2.3, mode and 0xf000 are sign extended, and 0x8000 isn't, so the test always fails, and doesn't map the file. Fudged this, and suddenly got a fault from user mode! Turns out EGCS 1.1.2 would have solved this... |
Aug 23-25 1999 |
Had a blitz on the MMU code and finally got it running.
Implemented page table related header files (uaccess.h,
pgtable.h and page.h). Faults are
now correctly detected, TLB entries are being created, and in faults
in kernel mode check extable to return an error when invalid.
The net result of this is that init now loads, generates faults in the kernel as the BSS is initialised, and then faults in user mode to bring in the code. Hello world from user mode now runs (although the only way to get the output was to add debugging code in write to print the argument, before it realises the FD wasn't open, and returns an error!). Removed a null pointer dereference in irq.c (useful tings these MMU's!) |
Aug 26 1999 | Finally replaced gcc with version 2.95.1. This means I can remove my hacks in the mmap code checking the file type. Added support for sh-linux target, and conditional use of an _ prefix for symbol names in the run time library. |
Aug 27 1999 |
Wrote a proper SH serial terminal driver. This is really just a port of
the existing kernel console driver into a serial driver framework,
i.e. still runs in polled mode. Now /dev/console
exists, and can be opened successfully, and maps onto the console
device. So when init writes hello world, it appears.
Beefed up the dummy init program a little. Converted the main program from asm to C, so it now prints 12 hello worlds. |
Aug 28-30 1999 | Didn't get too much done, despite this being a public holiday, the weather was too nice. |
Aug 31 1999 | As soon as init runs off the bottom of main, it faults on an illegal instruction (not surprisingly), so this started me looking at signal handling. Turned out to be fairly simple to implement, although it currently doesn't support restarting system calls. |
Sep 1 1999 | Restarting system calls when interrupted by a signal. Added extra code to the dummy init so that it blocks on a pipe, receives and alarm, and restarts the pipe read. Appears to work fine. |
Sep 2 1999 | Tidy up unimplemented functions which were cluttering up the output with warnings that they were unimplemented, but didn't appear to cause problems. Mostly cache flushing functions, which because the SH3 uses physical tags in the cache could simply be made no-op's. |
Sep 6 1999 | Started working on getting glibc running. Using the patches from Kaz Kojima I attempted to get a successful build. Fixed a few problems (his port is for SH4 not SH3, and the fact that I've modified gcc to not generate leading underscores in symbol names), but I then hit a brick wall trying to see how to build crtbegin.o and ctrend.o. |
Sep 7 1999 |
Found a mistake in building glibc. Kas had made a modification to glibc
to build these files, but in my modifications for the sh3, these weren't
getting built. Most of the other ports build these files as part of
gcc rather than glibc, so I've moved them there.
The build is getting a bit further now, but falls over when trying to do a link in the db2 subdirectory. Why is it trying to do a link...? |
Sep 9 1999 | Found my mistake in building glibc, the user configuration file is called configparms, not configparams as I had named it. Plonker. Next part of the process, trying to get crti.o and crtn.o to build. |
Sep 11-12 1999 |
I seem to be making a large number of silly mistakes getting glibc to
build. After spending a while trying to work out why crti.o and crtn.o
wouldn't build, remembered that Kas had explained that the build didn't
work for SH in his README. Ahhh!
Once you know where to look, it is obvious why these files will not build for the Super-H. Tried a few alternatives anyway (I think I'll take up bagging my head against brick walls next...). Spent a while playing with the makefiles to get a `generic' solution to this problem. It is now possible to supply an architecture dependent version of these files, rather then rely on the very weird build used for the other architectures. So glibc now build cleaning from start to finish! Next problem, can I get gcc to build a complete program? Short answer, no. The link line generated by gcc doesn't have the full paths for the some of the crt??? files. Turns out that where the glibc install process places them is only searched by gcc when not cross compiling. |
Sep 18-19 1999 |
Made a little more progress this weekend.
Minor mods to gcc and binutils to make building user programs
easier. Should only need to specify little endian now, and everything
else should default correctly. Probably need to think about supporting
a little endian build so that is the default.
Also fixed a problem with page sizes in binutils, so adjacent segments are now correctly merged. Can now build user programs more easily. |
Sep 21 1999 | Found that forkdidn't work, which was a bit embarrassing. Weird failure mode, just caused the CPU to lock up, not fault or reboot. Finally track it down to the page table manipulation which takes place on a fork. The VALID bit was being cleared, so the TLB miss handler was finding a page table entry, installing it, and then immediately being re-entered because the entry it had just installed was invalid! Now I just need to work out why... |
Sep 22 1999 | Grand check-in. Merged in changes from home into CVS. |
24 Sep to 3 Oct 1999 | Walking on the Scottish island of Skye. Great walking following the route in A Long Walk on the Isle of Skye. I can thoroughy recommend the Duntulm Castle Hotel where they made four hungry, wet and slightly smelly walkers exceedingly welcome. |
5 Oct 1999 |
Tracked down the problem with fork. Mainly due to a understanding of
how the MIPs (which I'd copied) implemented the writable/dirty and
readable/accessed features by using the hardware dirty and valid
bits respectivly. Once I'd sorted this out, it turned out I needed to
fix a whole host of little things:
a = fork(); while (1) { write(1, (a==0) ? "1" : "0", 1); } |
15 Oct 1999 | Spent a little while getting sash (a small shell with many utilities built in) to build. Threw up some oddities in the gcc library (in particular with mknod) but the resulting program, even though it was only 300K, was still too big to run. |
This I eventually did, and after porting some bootstrapping tools I needed to Linux, was able to restart.
Dec 24 1999 |
Started working on SH/Linux again. Had a look at the problems I was
having running the builtin version of ls in sash.
What appeared to be going wrong was the program
would do some memory allocation, and then access beyond the end of
memory allocated using brk from inside malloc.
Spent a while trying to find a problem in the kernel memory allocation,
before realising that it could also be caused by the program corrupting
memory, and indeed this was what was happening. glibc constructs
a list of search paths for dynamic loading, however in the statically
linked version, this path is empty, but the code in the library assumes
the path can never be empty. Fixed this, and sash burst into life!
Along the way came across another problem. The ioctl system call encodes in the request number the size of the third argument, which in the case of TCGETS is a struct termios. However this struct has different definitions in the kernel and the C library, which changes its size, and hence the value of TCGETS. The common two solutions for this are to define TCGETS so that it is a constant, and not dependent on the size of the struct, or redefine it in the C library so that the size is a char array or fixed size. MIPS takes the first approach, which is easier, so for now I'll do that, but without a written ABI this yet another potential incompatibility. Also found a fixed another problem. glibc uses a different layout for struct stat than the one used by the kernel, and needs a machine specific definition of how the kernel will represent this, which was missing for sh. |
Dec 28 1999 | Spent a little while looking at why programs called from sash didn't appear to get the correct command line arguments. Found a problem in strlen_user which returns the string length including the trailing 0, unlike the C library. |
Dec 29 1999 |
A bit more playing with sash. Sorted out a couple of problems:
|
Dec 30 1999 | Now sash appears to be up a running I wanted some data to play with, so tried building a kernel with a proc filesystem. Needed to implement a couple of architecture specific functions, to display CPU and interrupt details, but looks fine now. |
Dec 31 1999 | Having got most things working with the cache turned off, thought it was about time time to turn it on. Unlike the SH3, the SH4 needs some cache support functions, because of the separate instruction and data caches. Implemented these, following the PowerPC example, which only requires flush_icache_range and flush_page_to_ram, because of the caches being physically tagged. This works fine at the moment. However this won't address then synonym problem, which will require further work. |
Jan 1 2000 | Thought I'd have a go at getting networking going. Initially it appeared that all that would require doing was implementing the checksum functions. Given that Kaz had done this already there didn't seem any point in doing so again, so copied his. Updated the SCI driver to work with the SCIF as well (although not using the FIFO to receive). This allowed me to test sending data from serial port to serial port, giving the serial port driver a real work out for the first time. This showed up a problem which looks like difficulties sending more than 16 characters rapidly, |
Jan 3 2000 | Improved the SCIF serial port driver, so it now handles FIFO overruns, and parity errors correctly. This allows me to get most of the way through PPP connection set up, but got checksum errors after a while. Turned out I was still doing LF to LF/CR conversion. Fixed this and PPP negotiation completed. Can even ping the SH now! |
Jan 6 2000 | Not a lot of time to look at Linux today, but implemented a couple of missing functions, sys_gettimeofday and sys_settimeofday. |
Jan 7-8 2000 | While working on getting pppd up and running, I'd noticed that sometimes the first time I ran it it fell over with assorted faults, however the second run was always fine. After a bit of digging it looked like this was due to the first run needing to swap out some pages, while the second didn't. After a while I finally realised that this was due to the flush_tlb_page not always working. This was because the ASID comparison was wrong: gcc was optimising away assignments to the PTEH register. Added a couple of volatile qualifiers, and that problem looks fixed. |
Jan 9 2000 |
Having got pppd up and running, I wanted to try some more network tests.
First I wanted to try mounting an NFS filesystem, but realised that
the version of mount built into sash can't cope with NFS filesystems.
So tried to build a real mount executable, and hit a problem in glibc.
The symbol fflush_unlocked was being used, but this appears to
only be built when one of the ...REENTRANT macros is being
defined, however most other functions like this have a weak alias to the
normal version, which fore some reason, is missing from the fflush version.
Added this, rebuilt glibc, mount, and now I can mount NFS filesystems!
Next experiment was to get a telnetd up and running. This built nice and easily (with a little hack to get rid of a dependency on having a termcap library), and ran, but I was unable to connect. It appeared that the Linux kernel was rejecting the connection request, so I put a printk in the loop which compares the connection request with the list of sockets which have been bound, and suddenly I could connect. Looks like an optimisation problem maybe. Anyway, telnetd then rejected the connection request, because it was unable to do a chown on the pseudo TTY (not surprising given that the inode is on a ROM disk!). Looks like I need a RAM disk. |
Jan 10 2000 | Started looking at getting a RAM disk up and running. Rather than build mkfs I thought I'd try and get the initialised RAM disk up and running. Building a kernel containing data which can be used to initialise the RAM disk wasn't too difficult, and I've made the modifications so that /dev/initrd now works. Unfortunately when initialising the RAM disk, it now runs out of memory. With a compressed one however, it works a treat. |
Jan 11 2000 | Finally found a working tape drive at work, so I can now start synchronising the CVS repository at work with all the changes made at home over the Christmas holidays. |
Jan 12 2000 | Went skiing at the Tamworth Snowdome. |
Jan 13 2000 | My legs ache. See previous days entry. |
Jan 15-23 2000 | Continued checking in sources. This took longer than expected, because I took at as an opportunity to tidy some things up, and so broke things. Fortunately this was as expected, so I had kept a backup, and getting everything back together wasn't too bad. |
Jan 24 2000 |
I'd been seeing some odd behaviour while removing printk's from the
kernel. In at least one case removing the printk stopped this code
working. It looked like this could be due to an optimisation
problem, but an alternative way of fixing it was to switch to building
for SH4 (until this point I'd still been building for SH3). Unfortunatly
this changed the code so much I couldn't tell what had been causing the
problem.
Also spent a while trying to get telnetd to spawn a shell. Still some problems while setting up pseudo terminals in glibc. I'm not sure what is going on. Initially I thought it was due to removing printk's again, but the problem appears to move about when making small changes to the kernel. Compiler optimisation problems? Seems unlikly, as does an underlying problem with the interrupt code. |
Jan 29 to Feb 5 2000 | Skiing in Chamonix. A great time was had by all. |
Feb 13 2000 |
Got back to Linux again, and found out why I'd been having problems. It
was nothing to do with kernel bugs, or compiler problems, I was just running
out of memory! Increased the ammount of memory Linux knows about from 4M
to 16M, and everything has burst into life! I feel like a `screen shot':
%telnet 138.198.11.2 Trying 138.198.11.2... Connected to 138.198.11.2. Escape character is '^]'. Linux 2.2.9 ((none)) (ttyp0) (none) login: stuart Password: No directory /home/users/stuart! Logging in with home = "/". Stand-alone shell (version 2.1) > -ls . .. bin dev etc hello proc root sbin > exit Also fixed the PC and SP printed in /proc/n/stat. |
Feb 19-20 2000 | Final check-ins, and last minute tidy up prior to first release. Removed virtually all warnings from the build, implemented a few more functions which were still dummied out, and sorted out a remaining problem with varargs in gcc. |
Feb 21 2000 | Generated the patches and uploaded them to the FTP server. Updated the building instructions and virtually all of the other web pages to bring them up to date. |