Author Topic: Questions about porting kernel  (Read 2494 times)

Rick_B

  • Guest
Questions about porting kernel
« on: September 09, 2011, 01:55:51 pm »
Hello, I just discovered the Dingoo and I am really excited about it. I just have some basic questions about how you guys managed to put together a working kernel. I am a C programmer, but am trying to learn more about hardware. Any help you'd be willing to offer would be ultra-appreciated!

1.) I've compiled my own kernels so I know how to use make menuconfig and hand edit the file it creates. I know that certain patches are necessary for certain devices, so was that a first step in getting the kernel working? Does Ingenic supply official patches? Is there already assembly code for MIPS in a standard kernel source distribution? Does any of this work with the Ingenic CPU?

2.) Drivers. Did you have to write drivers from scratch for the video, sound, buttons and such? Or did Dingoo or Ingenic supply these? Or, is the device using off-the-shelf stuff that already has drivers available? Were any drivers already included in the kernel source that worked with the Dingoo?

3.) How did you figure out how to flash the internal flash? Is the device using a standard interface for flashing? Does the internal flash hold the bootloader as well? Is there any documentation for this or did you have to figure it out by trial-and-error?

Sorry if this seems overly demanding of you guys' time, but I am really excited about learning more about this device and  writing some software for it!

mth

  • Posts: 317
Re: Questions about porting kernel
« Reply #1 on: September 10, 2011, 12:11:40 am »
1.) I've compiled my own kernels so I know how to use make menuconfig and hand edit the file it creates. I know that certain patches are necessary for certain devices, so was that a first step in getting the kernel working? Does Ingenic supply official patches? Is there already assembly code for MIPS in a standard kernel source distribution? Does any of this work with the Ingenic CPU?
Ingenic provides a kernel for their reference boards. The first Dingux kernel was made by booboo based on Ingenic's kernel. That started the whole Dingux scene.

If you're interested in learning I would rather recommend the OpenDingux kernel though. It is kept up to date (based on Linux 3.0 currently, as opposed to 2.6.24.3 for booboo's kernel) and the driver code is cleaner than Ingenic's, so easier to understand when you read it. See Building OpenDingux from sources for a quick start in building OpenDingux.

Dingoo support is layered as follows:

First there is generic MIPS support, this has been part of the kernel for a long time. It resides in the arch/mips/ directory.

On top of that there is JZ4740 platform support in arch/mips/jz4740/ and drivers in drivers/ (grouped by subsystem rather than platform). In booboo's kernel this has been provided by Ingenic, in OpenDingux this has been provided by Lars-Peter Clausen and other people, who originally wrote it for Qi Hardware's Ben NanoNote mini computer which also uses the JZ4740 SoC. The NanoNote drivers are being merged into the mainline kernel: several have been merged already and others need cleanups before they can be merged.

Finally there is specific support for the Dingoo A320. This consist of a kernel config (arch/mips/configs/a320_defconfig), a board definition (arch/mips/jz4740/board_a320.c) and a few other files (check the git history).

2.) Drivers. Did you have to write drivers from scratch for the video, sound, buttons and such? Or did Dingoo or Ingenic supply these? Or, is the device using off-the-shelf stuff that already has drivers available? Were any drivers already included in the kernel source that worked with the Dingoo?
Most drivers already existed from Ingenic or the Ben NanoNote. Sometimes they needed fixing or adapting though to be useful on the Dingoo. Other drivers had to be written from scratch.

Things like the GPIO map and the LCD init sequence had to be reverse engineered. This was done by booboo; he documented the process on his blog.

3.) How did you figure out how to flash the internal flash? Is the device using a standard interface for flashing? Does the internal flash hold the bootloader as well? Is there any documentation for this or did you have to figure it out by trial-and-error?
Most of it was discovered by booboo by reverse engineering. The earliest boot stage is documented by Ingenic, but the stages after that are not documented. You can learn more by reading booboo's blog and by checking out the OpenDingux board-a320.c, which contains the NAND partitioning. The jzboot tool can be useful in exploring the contents of the NAND, as well as for booting kernels via USB; you can build this tool as part of the xburst-tools package available from projects.qi-hardware.com.

Sorry if this seems overly demanding of you guys' time, but I am really excited about learning more about this device and  writing some software for it!
Please visit #dingoonity on freenode IRC some time, a lot of developers, porters and users hang out there.

Rick_B

  • Guest
Re: Questions about porting kernel
« Reply #2 on: September 10, 2011, 12:54:15 pm »
On top of that there is JZ4740 platform support in arch/mips/jz4740/ and drivers in drivers/ (grouped by subsystem rather than platform). In booboo's kernel this has been provided by Ingenic, in OpenDingux this has been provided by Lars-Peter Clausen and other people, who originally wrote it for Qi Hardware's Ben NanoNote mini computer which also uses the JZ4740 SoC. The NanoNote drivers are being merged into the mainline kernel: several have been merged already and others need cleanups before they can be merged.
So does the NanoNote use the same devices as the A320? Things like sound, USB, video etc? Or is some or all of this functionality built into the JZ4740?

Quote
Most drivers already existed from Ingenic or the Ben NanoNote. Sometimes they needed fixing or adapting though to be useful on the Dingoo. Other drivers had to be written from scratch.

Things like the GPIO map and the LCD init sequence had to be reverse engineered. This was done by booboo; he documented the process on his blog.
And these drivers are included in git, correct? I should just be able to grab the latest and have everything I need, yeah?

Quote
Most of it was discovered by booboo by reverse engineering. The earliest boot stage is documented by Ingenic, but the stages after that are not documented. You can learn more by reading booboo's blog and by checking out the OpenDingux board-a320.c, which contains the NAND partitioning. The jzboot tool can be useful in exploring the contents of the NAND, as well as for booting kernels via USB; you can build this tool as part of the xburst-tools package available from projects.qi-hardware.com.
I'll check it out. Is it possible to redo the partitions in an arbitrary way? I'm sure you're working on this, but it would be great to be able to boot from the internal flash and perhaps mount a portion of it as read/write so you could store executables on the flash, and just use the SD card for ROMs or save data.

Regarding compiling a toolchain for this CPU, what's the best approach? I have an Ubuntu system I use for Linux development and other things. I'm assuming using this system would make development much easier since the package manager makes installing necessary development tools way easier than Mac OS X, for example.

Thanks for the detailed reply! This is very cool stuff!

pcercuei

  • Posts: 1689
    • My devblog
Re: Questions about porting kernel
« Reply #3 on: September 10, 2011, 07:38:21 pm »
So does the NanoNote use the same devices as the A320? Things like sound, USB, video etc? Or is some or all of this functionality built into the JZ4740?
The sound, USB and LCD subsystems are built into the jz4740 chipset. On the Ben Nanonote, the jz drives the LCD screen directly; on dingoo, the jz drives the TV-out, and another chip (the ILI93xx) drives the internal SLCD screen.

Quote
And these drivers are included in git, correct? I should just be able to grab the latest and have everything I need, yeah?
Yes, you just need to checkout the kernel repo.

Quote
Regarding compiling a toolchain for this CPU, what's the best approach? I have an Ubuntu system I use for Linux development and other things. I'm assuming using this system would make development much easier since the package manager makes installing necessary development tools way easier than Mac OS X, for example.
Linux is generally a better platform when you need to deal with Linux.

mth

  • Posts: 317
Re: Questions about porting kernel
« Reply #4 on: September 11, 2011, 01:37:17 am »
Regarding compiling a toolchain for this CPU, what's the best approach? I have an Ubuntu system I use for Linux development and other things. I'm assuming using this system would make development much easier since the package manager makes installing necessary development tools way easier than Mac OS X, for example.
If you build from the opendingux-buildroot git repository, you'll get both a toolchain and a rootfs. Alternatively, you can download the toolchain tarball from the release page which contains a pre-built toolchain for x86 Linux.

 

Post a new topic