Building Linux kernel

https://github.com/MiSTer-devel/Main_MiSTer/wiki

Moderators: Mug UK, Zorro 2, spiny, Greenious, Sorgelig, Moderator Team

Sorgelig
Atari God
Atari God
Posts: 1507
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Building Linux kernel

Postby Sorgelig » Thu Jan 11, 2018 11:17 pm

I went by other way which should be faster and less resource consuming than initrd/initramfs

kolla
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Thu Sep 17, 2015 11:39 pm
Contact:

Re: Building Linux kernel

Postby kolla » Thu Jan 11, 2018 11:30 pm

Sorgelig wrote:I went by other way which should be faster and less resource consuming than initrd/initramfs


OK - still may be useful.
With a filesystem small enough, entire linux filesystem could be the initrd, built into the kernel image :)

Anyways, found my way around uboot, added "loop.max_part=8" to boot command line, and now I can mount partitions from MBR and RDB image files:

Code: Select all

# cd /media/fat/Amiga
# losetup -f mister.hdf
# cat /proc/partitions
major minor  #blocks  name

   1        0       8192 ram0
   1        1       8192 ram1
   7        0     655360 loop0
   7        1     104580 loop0p1
   7        2     218106 loop0p2
   7        3     200970 loop0p3
   7        4     131418 loop0p4
 179        0    7716864 mmcblk0
 179        1    7202816 mmcblk0p1
 179        2     512000 mmcblk0p2
 179        3       1023 mmcblk0p3
#
# mount -t affs /dev/loop0p4 /mnt/amiga/dh3
# df -T /mnt/amiga/dh3
Filesystem     Type 1K-blocks   Used Available Use% Mounted on
/dev/loop0p4   affs    131417 116626     14792  89% /mnt/amiga/dh3


Yay :)

Next mission is adding some usb wifi support and add wpa_supplicant to userland.
-- kolla

Sorgelig
Atari God
Atari God
Posts: 1507
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Building Linux kernel

Postby Sorgelig » Fri Jan 12, 2018 12:06 am

kolla wrote:Anyways, found my way around uboot, added "loop.max_part=8" to boot command line, and now I can mount partitions from MBR and RDB image files:

do you mean you couldn't mount partitions on loop devices before?

kolla wrote:With a filesystem small enough, entire linux filesystem could be the initrd, built into the kernel image

it's easy in theory, but not so easy in practice, especially if you use u-boot which has slightly different view on "right" kernel image.

kolla wrote:Next mission is adding some usb wifi support and add wpa_supplicant to userland.

don't forget that Linux part is supposed to be a read-only the whole time. Unless you use a special key combination or command line command to reboot the MiSTer, every reboot and poweroff is unsafe. You can easily corrupt your linux partition if it will be required to be mounted as read-write.

kolla
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Thu Sep 17, 2015 11:39 pm
Contact:

Re: Building Linux kernel

Postby kolla » Fri Jan 12, 2018 12:20 am

Sorgelig wrote:
kolla wrote:Anyways, found my way around uboot, added "loop.max_part=8" to boot command line, and now I can mount partitions from MBR and RDB image files:

do you mean you couldn't mount partitions on loop devices before?


Correct - could only mount "filesystem" images.

kolla wrote:With a filesystem small enough, entire linux filesystem could be the initrd, built into the kernel image

it's easy in theory, but not so easy in practice, especially if you use u-boot which has slightly different view on "right" kernel image.

Yes, I can imagine - one can always cheat using a "dummy kernel" that just kexec to the actual kernel, but it quickly gets a little complicated. :)

kolla wrote:Next mission is adding some usb wifi support and add wpa_supplicant to userland.

don't forget that Linux part is supposed to be a read-only the whole time. Unless you use a special key combination or command line command to reboot the MiSTer, every reboot and poweroff is unsafe. You can easily corrupt your linux partition if it will be required to be mounted as read-write.


Yes, I am aware. My idea is just add wpa_supplicant, and configure it to use a wpa_supplicant.conf located on the fat partition.
-- kolla

kolla
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Thu Sep 17, 2015 11:39 pm
Contact:

Re: Building Linux kernel

Postby kolla » Fri Jan 12, 2018 12:46 am

OK, I could need a little hint on how one build userland, rootfs and the stuff in addon.tar - is this based on the de10-nano distro that came with the box?
-- kolla

Sorgelig
Atari God
Atari God
Posts: 1507
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Building Linux kernel

Postby Sorgelig » Fri Jan 12, 2018 12:52 am

kolla wrote:Correct - could only mount "filesystem" images.

it seems there is no kernel config option for this. I will add this option to command line then.

kolla wrote:OK, I could need a little hint on how one build userland, rootfs and the stuff in addon.tar - is this based on the de10-nano distro that came with the box?

it's based on buildroot with my manual/scripting modifications.

kolla
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Thu Sep 17, 2015 11:39 pm
Contact:

Re: Building Linux kernel

Postby kolla » Sat Jan 13, 2018 12:26 am

Sorgelig wrote:it's based on buildroot with my manual/scripting modifications.


Would be nice to see how you do it...

Anyways, I cheated - I copied over binaries from a raspberry pi, wpa_supplicant with friends, a few libs and config, and presto - the mister is now on wifi! :D

Would be nice to do it "properly" though. :)

I put wpa_supplicant.conf in /media/fat/config, though I suspect that dir is intended solely for soft cores, but it just seems "messy" to have it on /media/fat :p
-- kolla

Sorgelig
Atari God
Atari God
Posts: 1507
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Building Linux kernel

Postby Sorgelig » Sat Jan 13, 2018 1:44 am

give me files you've used from RPi. I will see what can i do. May be i will be able to compile same files from buildroot.
In upcoming linux version, there will be new layout where linux folder on fat partition will be used to hold linux image and kernel. Probably same folder can be used for linux related configs.

kolla
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Thu Sep 17, 2015 11:39 pm
Contact:

Re: Building Linux kernel

Postby kolla » Sat Jan 13, 2018 2:11 am

Sorgelig wrote:give me files you've used from RPi. I will see what can i do. May be i will be able to compile same files from buildroot.
In upcoming linux version, there will be new layout where linux folder on fat partition will be used to hold linux image and kernel. Probably same folder can be used for linux related configs.


That would be cool - you have private message with link etc :)
-- kolla

Sorgelig
Atari God
Atari God
Posts: 1507
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Building Linux kernel

Postby Sorgelig » Mon Jan 15, 2018 3:59 am

New Linux release has WiFi support.
Put your SSID/Pass to _wpa_supplicant.conf and rename it to wpa_supplicant.conf

kolla
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Thu Sep 17, 2015 11:39 pm
Contact:

Re: Building Linux kernel

Postby kolla » Mon Jan 15, 2018 9:43 am

Awesome, looking forward to try it out tonight!
-- kolla

kolla
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Thu Sep 17, 2015 11:39 pm
Contact:

Re: Building Linux kernel

Postby kolla » Mon Jan 15, 2018 11:06 pm

Hehe, by luck the exact kernel modules that I need for my USB wifi sticks were not enabled :)

For sake of (my) convenience, maybe you could add for next release...

Code: Select all

-# CONFIG_RT2800USB_RT53XX is not set
-# CONFIG_RT2800USB_RT55XX is not set
+CONFIG_RT2800USB_RT53XX=y
+CONFIG_RT2800USB_RT55XX=y


So, I built my own kernel, but then realized that I need a zImage_dtb and not just a zImage - I have looked at various online resources, but not really found a how-to for going from having a zImage to having a zImage_dtb, seems to vary a bit from device to device?

Thanks again :)
-- kolla

Sorgelig
Atari God
Atari God
Posts: 1507
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Building Linux kernel

Postby Sorgelig » Tue Jan 16, 2018 12:25 am

zImage_dtb is a simple concatenation of zImage and socfpga.dtb

I've updated the kernel. Get it from here: https://github.com/MiSTer-devel/Linux_I ... tor_MiSTer

kolla
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Thu Sep 17, 2015 11:39 pm
Contact:

Re: Building Linux kernel

Postby kolla » Tue Jan 16, 2018 2:10 am

Brilliant! I needed a piece of firmware too (rt2870.bin - forgot to mention it), just put it in the firmware.tar.gz file, ran the create_img.sh, copied over the resulting image, and presto - the mister is online with wifi symbol in menu and all :)

So, with my own kernel I can just do a

Code: Select all

cat zImage socfpga.dtb > zImage_dtb

or vice versa? :)

Thanks a lot!
-- kolla

Sorgelig
Atari God
Atari God
Posts: 1507
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Building Linux kernel

Postby Sorgelig » Tue Jan 16, 2018 2:20 am

kolla wrote:I needed a piece of firmware too (rt2870.bin - forgot to mention it), just put it in the firmware.tar.gz file, ran the create_img.sh, copied over the resulting image, and presto - the mister is online with wifi symbol in menu and all :)

Kernel source doesn't include firmwares for all devices due to license. Thus some wifi dongles will require additional steps to make them work. My ASUS dongle with realtek chip works without any additions.

kolla wrote:So, with my own kernel I can just do a
cat zImage socfpga.dtb > zImage_dtb


right.


Return to “MiSTer”

Who is online

Users browsing this forum: olin and 1 guest