hoglet67 / PiTubeDirect

Bare-metal Raspberry Pi project that attaches to the Acorn TUBE interface and emulates many BBC Micro Co Processors
GNU General Public License v3.0
188 stars 23 forks source link

Framebuffer not at expected address, messing up memory map #81

Closed hoglet67 closed 3 years ago

hoglet67 commented 4 years ago

On a 512MB Pi, the framebuffer is at a bus address of: 0x5EB64000

Which is an ARM address of: 0x1EB64000

cpu_mem is set to 16 (MB)

I would have thought this meant the top 16MB was used by the GPU (0x1F000000-0x1FFFFFFF on a 512MB machine), and that the frame buffer would be created within this memory.

(The FB should be 640x480x2 bytes = 0x307000)

This is going to mess up our memory map on a 256MB machine.

Setting gpu_mem to 16, 32 or 64 doesn't affect this.

Setting total_mem=384 changes it to 0x56B64000 / 0x16B64000 (which is expected).

Our memory map is currently:

# Memory map to stay compatible with 256MB Pi Models
#
# 0x00000000   0MB - Start of RAM
# 0xD8000000 216MB - ARM Basic (allow 4MB)
# 0x0DC00000 220MB - Stack space (allow 16 x 1MB)
# 0x0EC00000 236MB - Pi Kernel (allow 4MB)
# 0x0F000000 240MB - Top of cached RAM, start of GPU Memory
# 0x10000000 256MB - Top of physical RAM on 256MB Pi Model

So on a 256MB machine the Frame Buffer will end up at 0x0EB64000, which will collide with the stack space (!!)

Tried, by setting total_mem=256 and the system fails to boot.

hoglet67 commented 4 years ago

Command line reported by the Pi say:

           CMD_LINE : bcm2708_fb.fbwidth=1600 bcm2708_fb.fbheight=1200 bcm2708_fb.fbswap=1 dma.dmachans=0x7f35 bcm2708.boardrev=0x900093 bcm2708.serial=0x11807111 bcm2708.uart_clock=48000000 bcm2708.disk_led_gpio=47 smsc95xx.macaddr=B8:27:EB:80:71:11 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  copro=0 copro1_speed=3 copro3_speed=4 tube_delay=0 elk_mode=0

It looks like the frame buffer is being positioned just below vc_mem.mem_base=0x1ec00000

Not sure whether this is cause or effect.

hoglet67 commented 3 years ago

Reduced the size of the stacks from 1MB to 0.5MB.

# Memory map to stay compatible with 256MB Pi Models
#
# 0x00000000   0MB - Start of RAM
# 0x0D800000 216MB - ARM Basic (allow 4MB)
# 0x0DC00000 220MB - Stack space (allow 16 x 0.5MB)
# 0x0E400000 228MB - Pi Kernel (allow 4MB)
# 0x0E800000 232MB - Frame Buffer (allow 8MB)
# 0x0E800000 232MB - Top of cached RAM
# 0x0F000000 240MB - Start of GPU Memory
# 0x10000000 256MB - Top of physical RAM on 256MB Pi Model