Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,512 Views

Building a custom kernel for the DE1-SoC...

I want to add some devices to the kernel and have been following the ws2 linux kernel introduction for altera soc devices - lab 3 - soc fpga linux kernel (https://rocketboards.org/foswiki/view/documentation/ws2linuxkernelintroductionforalterasocdeviceslab...) guide and have hit a snag. 

 

Unless I am missing something, the line saying 

 

$ tar xvf patches.tgz 

 

Isn't preceded by a line telling us from where the patch should be downloaded. 

 

I can't find the patch so I can't continue. 

 

Does anyone know where the correct patch might be? 

 

Or does anyone have a better guide on how to build a kernel for a Terasic/Altera DE1-SoC? 

 

I will be very grateful for help, please.
0 Kudos
7 Replies
Altera_Forum
Honored Contributor I
203 Views

Hi, I am pretty sure the patches are in the SD Image (which contains the materials needed for the lab) as shown in this link: 

https://rocketboards.org/foswiki/view/documentation/ws2linuxkernelintroductionforalterasocdevices 

 

Try it:)
Altera_Forum
Honored Contributor I
203 Views

Thanks for taking the trouble to read & respond; I downloaded my image from the terasic site (http://www.terasic.com.tw/cgi-bin/page/archive.pl?language=english&categoryno=167&no=836&partno=4) and used the latest ubuntu release (http://www.terasic.com/downloads/cd-rom/de1-soc/linux_bsp/de1soc_ubuntu_1604.zip). 

 

I will follow your advice and do just that :). I hadn't even thought of that, I'll come back and let you know how I got on. 

 

Thanks again!
Altera_Forum
Honored Contributor I
203 Views

Yup, bang on reply; I have successfully built and run a kernel now - thank you very much. 

 

It just goes to show that RTFM has value ;). 

 

Great. I now have a kernel - what I really want is to boot from my new kernel into my Ubuntu release. 

 

I notice from the .config where the rootfs is being built 

CONFIG_BLK_DEV_INITRD=y CONFIG_INITRAMFS_SOURCE="../rootfs.cpio.gz" 

and thought it would be a breeze to expand the newly built zImage and drop in the corresponding rootfs from the Ubuntu zImage - but it's not that simple. 

 

I have spent a fair few hours trying to be clever and in humility would like some help please on getting my new kernel to boot Ubuntu. Ideas on a postcard please ;). 

 

Thanks again and I very much look forward to your reply.
Altera_Forum
Honored Contributor I
203 Views

My strategy was to create a working kernel build environment so that I can ensure the devices I need are built into the kernel. 

 

The second part of that strategy is that the kernel would boot into the ubuntu 1604 release anyone can download from the terasic site (http://www.terasic.com/downloads/cd-rom/de1-soc/linux_bsp/). 

 

I discovered that by using a variety of tools including binwalk I was able to recover the initramfs (rootfs.cpio) from my new kernel sunshine helped me to build. This rootfs.cpio initramfs is a given part of the WS2 project so I had it anyway, but it was proof that it could be done. Optimistically I had hoped to be able to do the same with the ubuntu zImage and use the extracted ubuntu initramfs as the initramfs of my new kernel. 

 

But alas the kernel seems to be built in a different manner and I have so far failed to recover the initramfs from the ubuntu zImage file; However I have managed to recover the ubuntu kernel .config file and it tells me that CONFIG_USB_SERIAL is not set, which explains a lot. 

# CONFIG_USB_SERIAL is not set  

... and CONFIG_USB_SERIAL_PL2303 is nowhere to be seen. 

 

So I am not going to get very far without those two as part of the kernel. 

 

If you know how I can go about building a kernel which will boot to an existing ubuntu installation, I really would be very grateful for your pearls of wisdom. 

 

I have had a look at altera's github (https://github.com/altera-opensource/linux-socfpga) but can't see which release (if any) corresponds to the Terasic Ubuntu 1604 release. 

 

If there is a better path and I am well and truly barking up the wrong tree, I will be delighted to be redirected and thanks for reading so far. 

 

I have spent far too much time on something which I thought would be the simplest part of the project; That would be OK if I was making progress. 

 

Yours very frustrated, Paul.
DRRB
Beginner
203 Views

Hi, better late than never.

I have done that with ubuntu 1604 sd image.

Like this :

  • Go to https://github.com/altera-opensource/linux-socfpga
  • Git clone the repo
  • Switch to an altera's branch like "git checkout  remotes/origin/socfpga-5.1"
  • Gunzip /proc/config.gz from DE1 board to .config
  • Do oldconfig, like "make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- oldconfig", lot of conf updates (4.5 vs 5.1)
  • Do menuconfig to add/config stuff
  • Build deb package with "make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j 8 KBUILD_DEBARCH=armhf deb-pkg"
  • Copy/scp deb files to DE1 board
  • install with "sudo dpkg -i *.deb"
  • Mount /dev/mmcblk0p1 on /boot and cd to it
  • Copy zImage to zImage.old (in case of problems)
  • Copy vmlinuz-5.1.0-00097-ga64da520ac0b to zImage
  • Sync
  • Reboot

 

Everything works here, eth (need to set a MAC address in uboot, EEPROM read fail), FrameBuffer, HPS/FPGA Bridges, regions...

 

Altera_Forum
Honored Contributor I
203 Views

I must've missed out the update in this thread - well, that's the drawback of subscribing to too many of these :)  

 

If you are doing something close to Terasic's 1604 release, note that you'll need the some additional frame driver that may not be included in the default .defconfig file. I would propose following the linaro's example here: 

https://rocketboards.org/foswiki/view/projects/sockitlinarolinuxdesktop 

 

except that you can switch out the kernel to Altera's own git and follow the instruction here: 

https://rocketboards.org/foswiki/view/documentation/embeddedlinuxbeginnersguide 

 

(press the > button until you reach "8. Configuring and Compiling Linux Kernel") 

 

Sorry I couldn't be of a better help, I've not ventured far down this path myself...
Altera_Forum
Honored Contributor I
203 Views

 

--- Quote Start ---  

I must've missed out the update in this thread - well, that's the drawback of subscribing to too many of these :)  

 

If you are doing something close to Terasic's 1604 release, note that you'll need the some additional frame driver that may not be included in the default .defconfig file. I would propose following the linaro's example here: 

https://rocketboards.org/foswiki/view/projects/sockitlinarolinuxdesktop 

 

except that you can switch out the kernel to Altera's own git and follow the instruction here: 

https://rocketboards.org/foswiki/view/documentation/embeddedlinuxbeginnersguide 

 

(press the > button until you reach "8. Configuring and Compiling Linux Kernel") 

 

Sorry I couldn't be of a better help, I've not ventured far down this path myself... 

--- Quote End ---  

 

Thanks sunshine for having a look, I'll check out the links. 

 

The SoC is talking to a server where it would be easy for me to add the GPS and modify the kernel if need be, another member of the team has put this forward which would mean I may not have to worry about the SoC talking to the GPS - however I will still pursue it as I'd like the option. 

 

I'll let you know how I get on. 

 

Thanks again!
Reply