Sunday, November 7, 2010

hwinit fixed

I just modified hwinit (in the subversion repository) so it works on all A320 out there. These are the changes:
  • Added WP bit clean in CP0 CAUSE register (original idea by BouKiCHi).
  • Added LCD init and logo display as visual feedback of hwinit success (original idea also by BouKiCHi).
  • Code cleanup and removal of unneeded nand code.
Kudos to BouKiCHi for an awesome work of debugging.

The first fix is just weird. CP0 means "coprocessor 0" in MIPS architechture. It's the part that takes care of memory management, exceptions, privilege levels and such. It turns out that some versions of the IPL (Initial Program Loader) ROM code in the JZ4732 set up the WATCH registers in such a way that a watch exception occurs but it deferred (by setting the bit WP in the abovementiones CAUSE register). Then later, when the linux kernel boots, as soon as it sets up the CP0 STATUS register (another special regitser of the same "coprocessor"), the WATCH exception is immediately serviced, caused an unhandled exception panic (that is: for people suffering this problem, hwinit was actually working, but the kernel was panicking way before the LCD was initialized, so they could see nothing at all).

Why some IPL ROM versions behave this way is a mystery, and would be harmless if the kernel MIPS initialization code was careful enough as to clear the WP bit before setting up the CP0 STATUS register (I bet this is fixed in more recent kernels, but I'm too lazy to verify it).

I'm working to provide a native firmware based dual boot installer, so this hwinit issue wasn't really top priority, but it had bugged me for so long that I just had to sort it out before continuing. I'm just like that, like to walk on solid ground and feel very uncomfortable when I leave loose ties behind me.

I won't make a new dual boot installer release with just the fixed hwinit, since by now I guess all those with trouble have eventually been lead to hwinit2. Next release should, in my opinion, include at least:
  • A newer kernel with:
  1. Fixed I/O corruption bug(either Ingenic or OpenDingux based).
  2. with support for newer flash chips in recent A320.
  3. Support for x760+.
  • An updated buildroot and toolchain, with both 32 and 64 bit versions. I had to upgrade my buildroot since the old one didn't compile in my Ubuntu 10.04 x64 box.

4 comments:

  1. So, the new dualboot installer will be easier for noob install? :)

    ReplyDelete
  2. Yes, that's the idea: keep the noob away from usbtool and the USB driver nightmare.

    ReplyDelete