Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit ac6873c

Browse files
committed
Fix the graphics mess
We've had a problem since last august. If graphics worked on qemu, they did not work on hardware. If they worked on hardware, they did not work on qemu. The problem comes down to the nature of VESA setup and how it works. Quick tutorial. Kernels on hardware start in 16-bit mode, go to 32-bit mode, then 64-bit mode. The 16-bit code, and much 32-bit code, is not considered part of the kernel; it's setup stuff, tacked on once the kernel is built by scripts from the kernel Makefile. It's discarded once the real kernel starts. Think of the kernel as the spaceship, and this 16- and 32- bit stuff as the first and second stage. While in the 32-bit code, if VESA is enabled, the 32-bit code calls and sets it up. The whole pile of code is pretty nasty. That VESA interaction you see sometimes? Looks like this? Press <ENTER> to see video modes available, <SPACE> to continue, or wait 30 sec Mode: Resolution: Type: Mode: Resolution: Type: Mode: Resolution: Type: 0 F00 80x25 VGA 1 F01 80x50 VGA 2 F02 80x43 VGA 3 F03 80x28 VGA 4 F05 80x30 VGA 5 F06 80x34 VGA 6 F07 80x60 VGA 7 300 640x400x8 VESA 8 301 640x480x8 VESA That's being done BEFORE the 64-bit kernel boots, in 32-bit code. One reason to do this is it's pretty easy to call VESA BIOS setup calls from that 32-bit code, but a mess to do it from 64-bit. And BIOS calls are a security exposure anyway. So, the boot sequence: 16 bit -> 32 bit -> ask about VESA if it's enabled -> 64 bit What happens in kexec, i.e. when the webboot kernel boots the tinycore kernel? we did this: 16 bit -> 32 bit -> ask about VESA -> 64 bit now we do this: -> kexec new kernel -> new kernel 64 bit See the sequence? Second kernel's 32-bit code never runs. And there's a problem. The second kernel never gets to ask you about VESA mode. It has to be done in the first kernel. So we enable all the VESA framebuffer stuff. But what about hardware? Can't we just enable all the hardware? Well, ... that's a problem, because then the flow changes. Kexec starts the second kernel at the 64-bit entry point. 16 bit -> 32 bit -> 64 bit -> set up hardware And, when you kexec: we did this before: 16 bit -> 32 bit -> 64 bit -> set up hardware now we do this: -> kexec -> 64 bit -> set up hardware oh, oops. You can see the problem: we enter the new kernel at the 64-bit entry point, but it still wants to set up hardware, and that explains the hardware wedges we were having. So, this change enables all the VESA setup a kernel does in 32-bit, but nothing more. It certainly fixes the problems we've had on qemu. Will it work on hardware? We'll see. It should. But ... we'll see. The trick will be not getting in trouble by enabling graphics HARDWARE in the first kernel; let the kernel you kexec do that stuff. N.B. This works ok with qemu -kernel command. it does not work with booting a usb stick in qemu via syslinux, but it does work just fine on a thinkpad T510. I also include a syslinux.cfg.example to show what I did that worked. NOTE: you really need to pick a VESA type; if you don't, tinycore graphics won't work. Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
1 parent 1abd3d8 commit ac6873c

File tree

4 files changed

+125
-10
lines changed

4 files changed

+125
-10
lines changed

RR

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export PMEM_SIZE=4G
2+
export RAM_SIZE=8G
3+
export KERNEL=linux/arch/x86/boot/bzImage
4+
export INITRD=/tmp/initramfs.linux_amd64.cpio
5+
6+
/usr/bin/qemu-system-x86_64 \
7+
-machine q35 \
8+
-m $RAM_SIZE \
9+
-object rng-random,filename=/dev/urandom,id=rng0 \
10+
-device virtio-rng-pci,rng=rng0 \
11+
-netdev user,id=u1 -device rtl8139,netdev=u1 \
12+
-kernel $KERNEL \
13+
-initrd $INITRD \
14+
-vga std \
15+
-append "earlyprintk=ttyS0,115200,keep console=tty0 console=ttyS0 vga=ask memmap=1G!1G" \
16+
-serial stdio

config-4.12.7

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,9 @@ CONFIG_NET_VENDOR_INTEL=y
15501550
# CONFIG_E100 is not set
15511551
# CONFIG_E1000 is not set
15521552
# CONFIG_E1000E is not set
1553-
# CONFIG_IGB is not set
1553+
CONFIG_IGB=y
1554+
CONFIG_IGB_HWMON=y
1555+
CONFIG_IGB_DCA=y
15541556
# CONFIG_IGBVF is not set
15551557
# CONFIG_IXGB is not set
15561558
# CONFIG_IXGBE is not set
@@ -2122,11 +2124,11 @@ CONFIG_GAMEPORT=y
21222124
#
21232125
CONFIG_TTY=y
21242126
CONFIG_VT=y
2125-
# CONFIG_CONSOLE_TRANSLATIONS is not set
2127+
CONFIG_CONSOLE_TRANSLATIONS=y
21262128
CONFIG_VT_CONSOLE=y
21272129
CONFIG_VT_CONSOLE_SLEEP=y
21282130
CONFIG_HW_CONSOLE=y
2129-
# CONFIG_VT_HW_CONSOLE_BINDING is not set
2131+
CONFIG_VT_HW_CONSOLE_BINDING=y
21302132
CONFIG_UNIX98_PTYS=y
21312133
CONFIG_LEGACY_PTYS=y
21322134
CONFIG_LEGACY_PTY_COUNT=0
@@ -2270,6 +2272,7 @@ CONFIG_I2C_MUX_PINCTRL=y
22702272
# CONFIG_I2C_MUX_MLXCPLD is not set
22712273
CONFIG_I2C_HELPER_AUTO=y
22722274
CONFIG_I2C_SMBUS=y
2275+
CONFIG_I2C_ALGOBIT=y
22732276

22742277
#
22752278
# I2C Hardware Bus support
@@ -2849,7 +2852,74 @@ CONFIG_MFD_VX855=y
28492852
#
28502853
# Frame buffer Devices
28512854
#
2852-
# CONFIG_FB is not set
2855+
CONFIG_FB=y
2856+
# CONFIG_FIRMWARE_EDID is not set
2857+
CONFIG_FB_CMDLINE=y
2858+
CONFIG_FB_NOTIFY=y
2859+
# CONFIG_FB_DDC is not set
2860+
CONFIG_FB_BOOT_VESA_SUPPORT=y
2861+
CONFIG_FB_CFB_FILLRECT=y
2862+
CONFIG_FB_CFB_COPYAREA=y
2863+
CONFIG_FB_CFB_IMAGEBLIT=y
2864+
# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
2865+
# CONFIG_FB_SYS_FILLRECT is not set
2866+
# CONFIG_FB_SYS_COPYAREA is not set
2867+
# CONFIG_FB_SYS_IMAGEBLIT is not set
2868+
# CONFIG_FB_PROVIDE_GET_FB_UNMAPPED_AREA is not set
2869+
# CONFIG_FB_FOREIGN_ENDIAN is not set
2870+
# CONFIG_FB_SYS_FOPS is not set
2871+
# CONFIG_FB_SVGALIB is not set
2872+
# CONFIG_FB_MACMODES is not set
2873+
# CONFIG_FB_BACKLIGHT is not set
2874+
# CONFIG_FB_MODE_HELPERS is not set
2875+
# CONFIG_FB_TILEBLITTING is not set
2876+
2877+
#
2878+
# Frame buffer hardware drivers
2879+
#
2880+
# CONFIG_FB_CIRRUS is not set
2881+
# CONFIG_FB_PM2 is not set
2882+
# CONFIG_FB_CYBER2000 is not set
2883+
# CONFIG_FB_ARC is not set
2884+
# CONFIG_FB_ASILIANT is not set
2885+
# CONFIG_FB_IMSTT is not set
2886+
# CONFIG_FB_VGA16 is not set
2887+
CONFIG_FB_VESA=y
2888+
# CONFIG_FB_N411 is not set
2889+
# CONFIG_FB_HGA is not set
2890+
# CONFIG_FB_OPENCORES is not set
2891+
# CONFIG_FB_S1D13XXX is not set
2892+
# CONFIG_FB_NVIDIA is not set
2893+
# CONFIG_FB_RIVA is not set
2894+
# CONFIG_FB_I740 is not set
2895+
# CONFIG_FB_LE80578 is not set
2896+
# CONFIG_FB_MATROX is not set
2897+
# CONFIG_FB_RADEON is not set
2898+
# CONFIG_FB_ATY128 is not set
2899+
# CONFIG_FB_ATY is not set
2900+
# CONFIG_FB_S3 is not set
2901+
# CONFIG_FB_SAVAGE is not set
2902+
# CONFIG_FB_SIS is not set
2903+
# CONFIG_FB_VIA is not set
2904+
# CONFIG_FB_NEOMAGIC is not set
2905+
# CONFIG_FB_KYRO is not set
2906+
# CONFIG_FB_3DFX is not set
2907+
# CONFIG_FB_VOODOO1 is not set
2908+
# CONFIG_FB_VT8623 is not set
2909+
# CONFIG_FB_TRIDENT is not set
2910+
# CONFIG_FB_ARK is not set
2911+
# CONFIG_FB_PM3 is not set
2912+
# CONFIG_FB_CARMINE is not set
2913+
# CONFIG_FB_SMSCUFX is not set
2914+
# CONFIG_FB_UDL is not set
2915+
# CONFIG_FB_IBM_GXT4500 is not set
2916+
# CONFIG_FB_VIRTUAL is not set
2917+
# CONFIG_FB_METRONOME is not set
2918+
# CONFIG_FB_MB862XX is not set
2919+
# CONFIG_FB_BROADSHEET is not set
2920+
# CONFIG_FB_AUO_K190X is not set
2921+
# CONFIG_FB_SIMPLE is not set
2922+
# CONFIG_FB_SM712 is not set
28532923
# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
28542924
# CONFIG_VGASTATE is not set
28552925

@@ -2861,6 +2931,13 @@ CONFIG_VGA_CONSOLE=y
28612931
CONFIG_DUMMY_CONSOLE=y
28622932
CONFIG_DUMMY_CONSOLE_COLUMNS=80
28632933
CONFIG_DUMMY_CONSOLE_ROWS=25
2934+
CONFIG_FRAMEBUFFER_CONSOLE=y
2935+
# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
2936+
# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
2937+
CONFIG_LOGO=y
2938+
CONFIG_LOGO_LINUX_MONO=y
2939+
CONFIG_LOGO_LINUX_VGA16=y
2940+
CONFIG_LOGO_LINUX_CLUT224=y
28642941
# CONFIG_SOUND is not set
28652942

28662943
#
@@ -4322,6 +4399,10 @@ CONFIG_DDR=y
43224399
# CONFIG_IRQ_POLL is not set
43234400
CONFIG_MPILIB=y
43244401
CONFIG_OID_REGISTRY=y
4402+
CONFIG_FONT_SUPPORT=y
4403+
# CONFIG_FONTS is not set
4404+
CONFIG_FONT_8x8=y
4405+
CONFIG_FONT_8x16=y
43254406
# CONFIG_SG_SPLIT is not set
43264407
CONFIG_SG_POOL=y
43274408
CONFIG_ARCH_HAS_SG_CHAIN=y

syslinux.cfg.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
DEFAULT webboot
2+
SAY Now booting webboot
3+
PROMPT 1
4+
TIMEOUT 1
5+
6+
LABEL webboot
7+
KERNEL /boot/webboot
8+
INITRD /boot/webboot.cpio.gz
9+
APPEND earlyprintk=tty0 earlyprintk=ttyS0,115200,keep console=ttyS0 console=tty0 memmap=1G!1G vga=ask
10+
11+

webboot/webboot.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const (
4040
coreURL = "http://tinycorelinux.net/10.x/x86/release/CorePlus-current.iso"
4141
ubuURL = "http://releases.ubuntu.com/18.04/ubuntu-18.04.3-desktop-amd64.iso"
4242
archURL = "http://mirror.rackspace.com/archlinux/iso/2020.01.01/archlinux-2020.01.01-x86_64.iso"
43+
tcCmdLine = "memmap=%dG!%dG earlyprintk=ttyS0,115200 console=ttyS0 console=tty0 root=/dev/pmem0 loglevel=3 cde waitusb=5 vga=791"
4344
)
4445

4546
var (
@@ -52,30 +53,32 @@ var (
5253
ipv6 = flag.Bool("ipv6", true, "use IPV6")
5354
dryrun = flag.Bool("dryrun", false, "Do not do the kexec")
5455
wifi = flag.String("wifi", "", "[essid [WPA [password]]]")
56+
pmbase = flag.Int("pmbase", 1, "PM base in GiB")
57+
pmsize = flag.Int("pmsize", 1, "PM size in GiB")
5558
bookmark = map[string]*webboot.Distro{
5659
// TODO: Fix webboot to process the tinycore's kernel and initrd to boot from instead of using our customized kernel
5760
"webboot-tinycorepure": &webboot.Distro{
5861
"boot/vmlinuz64",
5962
"/boot/corepure64.gz",
60-
"memmap=1G!1G earlyprintk=ttyS0,115200 console=ttyS0 console=tty0 root=/dev/pmem0 loglevel=3 cde waitusb=5 vga=791",
63+
tinyCoreCmdLine(),
6164
wbtcpURL,
6265
},
6366
"webboot-corepure": &webboot.Distro{
6467
"boot/vmlinuz64",
6568
"/boot/corepure64.gz",
66-
"memmap=4G!4G earlyprintk=ttyS0,115200 console=ttyS0 console=tty0 root=/dev/pmem0 loglevel=3 cde waitusb=5 vga=791",
69+
tinyCoreCmdLine(),
6770
wbcpURL,
6871
},
6972
"tinycore": &webboot.Distro{
7073
"boot/vmlinuz64",
7174
"/boot/corepure64.gz",
72-
"earlyprintk=ttyS0,115200 console=ttyS0 console=tty0",
75+
tinyCoreCmdLine(),
7376
tcURL,
7477
},
7578
"Tinycore": &webboot.Distro{
7679
"/bzImage", // our own custom kernel, which has to be in the initramfs
7780
"/boot/corepure64.gz",
78-
"memmap=1G!1G earlyprintk=ttyS0,115200 console=ttyS0 console=tty0 root=/dev/pmem0 loglevel=3 cde waitusb=5 vga=791",
81+
tinyCoreCmdLine(),
7982
tcURL,
8083
},
8184
"arch": &webboot.Distro{
@@ -105,18 +108,22 @@ var (
105108
"local": &webboot.Distro{
106109
"/bzImage",
107110
"/boot/corepure64.gz",
108-
"memmap=256M!1G earlyprintk=ttyS0,115200 console=ttyS0 console=tty0 console=tty1 root=/dev/pmem0 loglevel=3 cde waitusb=5 vga=791",
111+
tinyCoreCmdLine(),
109112
"file:///iso", // NOTE: three / is REQUIRED
110113
},
111114
"core": &webboot.Distro{
112115
"boot/vmlinuz",
113116
"/boot/core.gz",
114-
"console=tty0",
117+
tinyCoreCmdLine(),
115118
coreURL,
116119
},
117120
}
118121
)
119122

123+
func tinyCoreCmdLine() string {
124+
return fmt.Sprintf(tcCmdLine, *pmsize, *pmbase)
125+
}
126+
120127
// parseArg takes a name of bookmark and produces a download link
121128
// The download link can be used to download data to a persistent memory device '/dev/pmem0'
122129
func parseArg(arg string) (string, string, error) {

0 commit comments

Comments
 (0)