From 7d77acbdc516fc0c4fccca9d2266177e05d97879 Mon Sep 17 00:00:00 2001 From: Andreas T Jonsson Date: Thu, 21 Nov 2024 15:27:33 +0100 Subject: [PATCH] More RPI5 fixes --- .github/workflows/rpi.yml | 2 +- front/rpi/Makefile | 2 +- front/rpi/kernel.cpp | 41 ++++++++++++++++++------ tools/package/itch/package.rasberrypi.sh | 5 +-- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/.github/workflows/rpi.yml b/.github/workflows/rpi.yml index 7599a02..40f56ab 100644 --- a/.github/workflows/rpi.yml +++ b/.github/workflows/rpi.yml @@ -28,7 +28,7 @@ jobs: run: | sudo apt-get update sudo apt-get install cppcheck - curl -L -o circle.zip https://github.com/virtualxt/circle/archive/refs/heads/master.zip + curl -L -o circle.zip https://github.com/virtualxt/circle/archive/refs/heads/develop.zip curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default && unzip butler.zip -d butler curl -L -o premake5.tar.gz https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-linux.tar.gz && mkdir premake5 && tar -xf premake5.tar.gz -C premake5 curl -L -o toolchain.tar.xz https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-aarch64-none-elf.tar.xz && tar -xf toolchain.tar.xz diff --git a/front/rpi/Makefile b/front/rpi/Makefile index dc0c518..6720052 100644 --- a/front/rpi/Makefile +++ b/front/rpi/Makefile @@ -6,7 +6,7 @@ endif LIBCHOME = $(VXTHOME)/../scanf C_STANDARD = -std=c11 -CFLAGS = -DVXT_NO_LIBC -DFRONTEND_VIDEO_RED=2 -DFRONTEND_VIDEO_GREEN=1 -DFRONTEND_VIDEO_BLUE=0 -DFRONTEND_VIDEO_ALPHA=3 -I$(VXTHOME)/include -I../common +CFLAGS = -DVXT_NO_LIBC -DFRONTEND_VIDEO_BLUE=0 -DFRONTEND_VIDEO_GREEN=1 -DFRONTEND_VIDEO_RED=2 -DFRONTEND_VIDEO_ALPHA=3 -I$(VXTHOME)/include -I../common OBJS_VXT = $(VXTHOME)/cpu.o \ $(VXTHOME)/disk.o \ diff --git a/front/rpi/kernel.cpp b/front/rpi/kernel.cpp index cd3f62f..2143e66 100644 --- a/front/rpi/kernel.cpp +++ b/front/rpi/kernel.cpp @@ -227,11 +227,13 @@ extern "C" { if (pFrameBuffer) delete pFrameBuffer; - CKernelOptions *opt = (CKernelOptions*)userdata; pFrameBuffer = new CBcmFrameBuffer((unsigned)width, (unsigned)height, 32); if (!pFrameBuffer->Initialize()) { VXT_LOG("Could not set correct ressolution. Fallback to virtual resolution."); + + delete pFrameBuffer; + CKernelOptions *opt = (CKernelOptions*)userdata; pFrameBuffer = new CBcmFrameBuffer(opt->GetWidth(), opt->GetHeight(), 32, (unsigned)width, (unsigned)height); if (!pFrameBuffer->Initialize()) { @@ -242,12 +244,23 @@ extern "C" { } } - u8 *buffer = (u8*)pFrameBuffer->GetBuffer(); + u8 *buffer = (u8*)(u64)pFrameBuffer->GetBuffer(); for (int i = 0; i < height; i++) { - memcpy(buffer, rgba, 4 * width); + // This is probably a firmware bug! + // The framebuffer should be 32 bit at this point. + #if RASPPI == 5 + #define COLOR(red, green, blue) (((red) & 0x1F) << 11 | ((green) & 0x1F) << 6 | ((blue) & 0x1F)) + for (int j = 0; j < width; j++) { + ((u16*)buffer)[j] = COLOR(rgba[2], rgba[1], rgba[0]); + rgba += 4; + } + #else + memcpy(buffer, rgba, 4 * width); + rgba += 4 * width; + #endif buffer += pFrameBuffer->GetPitch(); - rgba += 4 * width; } + return 0; } } @@ -353,6 +366,8 @@ TShutdownMode CKernel::Run(void) { if (log_file_name && (f_open(&log_file, log_file_name, FA_WRITE|FA_CREATE_ALWAYS) == FR_OK)) vxt_set_logger(&file_logger); #endif + + VXT_LOG("Machine: %s (%s)", CMachineInfo::Get()->GetMachineName(), CMachineInfo::Get()->GetSoCName()); bool has_floppy = true; FIL floppy_file; @@ -571,19 +586,25 @@ void CKernel::InitializeAudio(void) { const char *pSoundDevice = m_Options.GetSoundDevice(); if (pSoundDevice) { - if (!strcmp(pSoundDevice, "sndhdmi")) + if (!strcmp(pSoundDevice, "sndpwm")) + m_pSound = new CPWMSoundBaseDevice(&m_Interrupt, SAMPLE_RATE, CHUNK_SIZE); + else if (!strcmp(pSoundDevice, "sndhdmi")) m_pSound = new CHDMISoundBaseDevice(&m_Interrupt, SAMPLE_RATE, CHUNK_SIZE); - #if RASPPI >= 4 - if (!m_pSound && !strcmp(pSoundDevice, "sndusb")) + else if (!m_pSound && !strcmp(pSoundDevice, "sndusb")) m_pSound = new CUSBSoundBaseDevice(SAMPLE_RATE); #endif } - // Use PWM as default audio device. + // Use PWM or HDMI as default audio device. if (!m_pSound) { - pSoundDevice = "sndpwm"; - m_pSound = new CPWMSoundBaseDevice(&m_Interrupt, SAMPLE_RATE, CHUNK_SIZE); + //#if RASPPI <= 4 + pSoundDevice = "sndpwm"; + m_pSound = new CPWMSoundBaseDevice(&m_Interrupt, SAMPLE_RATE, CHUNK_SIZE); + //#else + // pSoundDevice = "sndhdmi"; + // m_pSound = new CHDMISoundBaseDevice(&m_Interrupt, SAMPLE_RATE, CHUNK_SIZE); + //#endif } VXT_LOG("Sound device: %s", pSoundDevice); diff --git a/tools/package/itch/package.rasberrypi.sh b/tools/package/itch/package.rasberrypi.sh index b0c5aaa..3f68de4 100755 --- a/tools/package/itch/package.rasberrypi.sh +++ b/tools/package/itch/package.rasberrypi.sh @@ -2,8 +2,9 @@ DIR=${GITHUB_WORKSPACE}/package -cp ${GITHUB_WORKSPACE}/kernel8-32.img ${DIR} -cp ${GITHUB_WORKSPACE}/kernel7l.img ${DIR} +cp ${GITHUB_WORKSPACE}/kernel8.img ${DIR} +cp ${GITHUB_WORKSPACE}/kernel8-rpi4.img ${DIR} +cp ${GITHUB_WORKSPACE}/kernel_2712.img ${DIR} cp boot/freedos_rpi_hd.img ${DIR}/C.img cp bios/GLABIOS.ROM ${DIR}