Skip to content

Commit

Permalink
More RPI5 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-jonsson committed Nov 21, 2024
1 parent b62d868 commit 7d77acb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion front/rpi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
41 changes: 31 additions & 10 deletions front/rpi/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions tools/package/itch/package.rasberrypi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 7d77acb

Please sign in to comment.