RP2040/Pico beeb emulator

discuss bbc micro and electron emulators (including mame) here!
folly
Posts: 10
Joined: Sun Mar 21, 2021 1:41 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by folly »

I want to share my findings about connecting the keyboard to the pico
I compiled with -DUSE_USB_KEYBOARD=1 so I could use the keyboard.

When connected to an old monitor the keyboard stopped working sometimes, so I had to reboot.
On a new monitor I didn't have this problem.
So this made me wonder how this could be different.
In both ways I had, more or less, coloured lines showing up, when pressing the keyboard.
This could be explained though.
Using a DAC for VGA isn't a perfect solution, so sometimes we see the voltage fluctuations on the display.

I use a breadboard with resistors for the VGA.
Looking at the schematics of the demo-board, 47 Ohm resistors are used for Hsync and Vsync.
Seems they are low because the Hsync and Vsync can take 3 Volt, as I recall.
But what if the monitor resistance on these lines are too low, it will possibly draw too much current from the pico,
Perhaps preventing the keyboard from working again.

So I tried higher resistor values :
- with 120 Ohm had same result with the keyboard
- with 560 Ohm the keyboard kept working on both monitors

So basically the Hsync and Vsync lines also work with less voltage on them.
And it seems these resistor values have influence on the keyboard's ability to work.
I noticed though, the screen seems to go a bit off-center (to the left).
With auto calibration it goes back to OK.

I hope it's useful information.
User avatar
anightin
Posts: 970
Joined: Thu Aug 23, 2018 2:03 pm
Location: Cambridge UK
Contact:

Re: RP2040/Pico beeb emulator

Post by anightin »

anightin wrote: Sun Mar 21, 2021 8:00 pm
kilog wrote: Sun Mar 21, 2021 3:12 am
anightin wrote: Fri Mar 19, 2021 10:35 am

In that case I'll modify my feedback to say that there is right and bottom border on my widescreen display, with the hack reducing some of the right hand border :D
Yeah, i think it will like another mode better with a smaller horizontal total. does it show show what it thinks the mode is resolution wise in the menu anywhere?
I seem to remember 1125p showing up on my OSSC but now I can feed it direct into my monitor with the VGA adapter I'll take a look when I'm next in the workshop and post back.
So I had a play with my OSSC settings and looks like taking the horizonal and vertical back porch values down to single digits allows me to centre the image at least. It is reporting a 1920x1080 image at 50Hz, but by default was displaying it with bottom and right borders, and a 'negative' left border:
IMG_8937.jpeg
kilog
Posts: 51
Joined: Mon Jul 13, 2020 2:58 am
Contact:

Re: RP2040/Pico beeb emulator

Post by kilog »

i had a quick play with different 1080p 50 timings for VGA and generally my monitors liked them less
folly
Posts: 10
Joined: Sun Mar 21, 2021 1:41 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by folly »

Any news on this fork ?

For those who are interested I made an experimental module-script for the "pico beeb emulator" for RetroPie using this fork.
Here you can find the experimental module-script :
https://github.com/FollyMaddy/RetroPie- ... pico-pi.sh
This version works with RPI4.
Remove this, " -DDRM_PRIME=1", inside the module-script and it will work on RPI3 too.
It runs in a match-box windows.

Edit : update : exiting can now be done with ctrl+c
Last edited by folly on Tue May 18, 2021 6:55 pm, edited 1 time in total.
kilog
Posts: 51
Joined: Mon Jul 13, 2020 2:58 am
Contact:

Re: RP2040/Pico beeb emulator

Post by kilog »

I'm currently working on other things. Surprised that DRM_PRIME doesn't work on Pi3; does for me. You on latest OS?
folly
Posts: 10
Joined: Sun Mar 21, 2021 1:41 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by folly »

Other stuff !
I hope you will be making nice things :-)

We are on the latest OS.
Oh yea, forgot to tell.
Indeed, you are right, using "-DDRM_PRIME=1" does work if you use the experimental GL driver on RPI3.
But I had to find another solution because RetroPie doesn't support the experimental GL driver.
Then it will break things or you have to install many things from source.
Not using "-DDRM_PRIME=1" made it working with the normal driver of raspberry pi os.
But it's slower now.
Or am I missing something here ?

Btw. I saw a DRI2 failure in the log, what does that mean ?
kilog
Posts: 51
Joined: Mon Jul 13, 2020 2:58 am
Contact:

Re: RP2040/Pico beeb emulator

Post by kilog »

folly wrote: Tue May 18, 2021 7:04 pm Other stuff !
I hope you will be making nice things :-)
A little time to make nice things... also some cool things.
We are on the latest OS.
Oh yea, forgot to tell.
Indeed, you are right, using "-DDRM_PRIME=1" does work if you use the experimental GL driver on RPI3.
But I had to find another solution because RetroPie doesn't support the experimental GL driver.
Then it will break things or you have to install many things from source.
Not using "-DDRM_PRIME=1" made it working with the normal driver of raspberry pi os.
But it's slower now.
Or am I missing something here ?

Btw. I saw a DRI2 failure in the log, what does that mean ?
Ah, yeah i didn't spent too much time messing with the EGL/DRI3 stuff as I haven't really played that much with that stuff b4, but wanted to improve on the atrocious copy-up speed on the older Pis (I guess I was always using the experimental driver!).
Someone with more SDL experience may be able to sort it out, I couldn't get SDL/EGL/DRI to play together, but then I didn't even know you had to pick a different SDL driver for EGL, so perhaps I could have gotten away without dropping to raw X for the GUI.

Hopefully someone can knock it into shape.
folly
Posts: 10
Joined: Sun Mar 21, 2021 1:41 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by folly »

Thanks for explaining.

If you are interested you can look at the thread from here :
https://retropie.org.uk/forum/topic/294 ... ron-emu/49
Silversmurfer
Posts: 4
Joined: Mon May 24, 2021 5:27 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by Silversmurfer »

Hi all and thanks for adding me.
I've been trying to compile B-Em for the pico pi and I'm getting the same error on cmake whether it's on my mac or pi 4

CMake Error at src/pico/CMakeLists.txt:327 (target_compile_definitions):
Cannot specify compile definitions for target "slower_boot2" which is not
built by this project.

Is this something I'm missing or haven't configured ?

thanks in advance !
kilog
Posts: 51
Joined: Mon Jul 13, 2020 2:58 am
Contact:

Re: RP2040/Pico beeb emulator

Post by kilog »

Hi all and thanks for adding me.
I've been trying to compile B-Em for the pico pi and I'm getting the same error on cmake whether it's on my mac or pi 4
What did you do? CMake args etc?? :-)

I assume you are following the instructions in the README.md in the kilograham b-em repo, or something else?
Silversmurfer
Posts: 4
Joined: Mon May 24, 2021 5:27 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by Silversmurfer »

Hi thanks for the reply - yep I believe I was following the instructions on the Github page

The Pi and the host versions both make and compile ok

here's the cmd line and output in full

Nik

pi@raspberrypi:~/pico/b-em/pico-build $ cmake -DPICO_SDK_PATH=/home/pi/pico/pico-sdk -DPICO_BOARD=vgaboard ..
Building b-em for RP2040 using the Pico SDK
PICO_SDK_PATH is /home/pi/pico/pico-sdk
PICO platform is rp2040.
PICO compiler is
PICO_GCC_TRIPLE defaulted to arm-none-eabi
PICO target board is vgaboard.
Using board configuration from /home/pi/pico/pico-sdk/src/boards/include/boards/vgaboard.h
TinyUSB available at /home/pi/pico/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; adding USB support.
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
Using PICO_EXAMPLES_PATH from environment ('/home/pi/pico/pico-examples')
PIOASM will need to be built
lwIP available at /home/pi/pico/pico-extras/lib/lwip/src/core/tcp.c; TCP/IP support is available.
PICO_GCC_TRIPLE defaulted to arm-none-eabi
Skipping b-em for Pico SDK build
Skipping b-em-reduced for Pico SDK build
Skipping b-em-reduced-thumb-cpu for Pico SDK build
{$NAME} DISCS=discs/beeb_discs.txt ROMS=roms/beeb_roms.txt
Configured beeb TUBE=0 DEBUGGER=0 SID= PICO_CPU=1 GUI= SAVE= VDFS=0 FDI= UEF= CSW= IDE= SCSI= ADC= MOUSE= MUSIC5000= I8271=
ELF2UF2 will need to be built
EmbedTool will need to be built
{$NAME} DISCS=discs/master_discs.txt ROMS=roms/master_roms.txt
Configured master TUBE=0 DEBUGGER=0 SID= PICO_CPU=1 GUI= SAVE= VDFS=0 FDI= UEF= CSW= IDE= SCSI= ADC= MOUSE= MUSIC5000= I8271=
{$NAME} DISCS=discs/beeb_discs.txt ROMS=roms/beeb_roms.txt
Configured beeb_1080p TUBE=0 DEBUGGER=0 SID= PICO_CPU=1 GUI= SAVE= VDFS=0 FDI= UEF= CSW= IDE= SCSI= ADC= MOUSE= MUSIC5000= I8271=
WEEVAL beeb_1080p
{$NAME} DISCS=discs/master_discs.txt ROMS=roms/master_roms.txt
Configured master_1080p TUBE=0 DEBUGGER=0 SID= PICO_CPU=1 GUI= SAVE= VDFS=0 FDI= UEF= CSW= IDE= SCSI= ADC= MOUSE= MUSIC5000= I8271=
WEEVAL master_1080p
{$NAME} DISCS=discs/beeb_discs.txt ROMS=roms/beeb_roms.txt
Configured beeb_360 TUBE=0 DEBUGGER=0 SID= PICO_CPU=1 GUI= SAVE= VDFS=0 FDI= UEF= CSW= IDE= SCSI= ADC= MOUSE= MUSIC5000= I8271=
{$NAME} DISCS=discs/master_discs.txt ROMS=roms/master_roms.txt
Configured master_360 TUBE=0 DEBUGGER=0 SID= PICO_CPU=1 GUI= SAVE= VDFS=0 FDI= UEF= CSW= IDE= SCSI= ADC= MOUSE= MUSIC5000= I8271=
CMake Error at src/pico/CMakeLists.txt:326 (pico_define_boot_stage2):
pico_define_boot_stage2 Function invoked with incorrect arguments for
function named: pico_define_boot_stage2


CMake Error at src/pico/CMakeLists.txt:327 (target_compile_definitions):
Cannot specify compile definitions for target "slower_boot2" which is not
built by this project.


-- Configuring incomplete, errors occurred!
See also "/home/pi/pico/b-em/pico-build/CMakeFiles/CMakeOutput.log".
See also "/home/pi/pico/b-em/pico-build/CMakeFiles/CMakeError.log".

CMakeError.log
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /usr/bin/arm-none-eabi-gcc
Build flags:
Id flags:

The output was:
1
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
/tmp/building/package/build/arm-none-eabi/newlib/libc/stdlib/../../../../../newlib/libc/stdlib/exit.c:64: undefined reference to `_exit'
collect2: error: ld returned 1 exit status


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: /usr/bin/arm-none-eabi-g++
Build flags:
Id flags:

The output was:
1
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
/tmp/building/package/build/arm-none-eabi/newlib/libc/stdlib/../../../../../newlib/libc/stdlib/exit.c:64: undefined reference to `_exit'
collect2: error: ld returned 1 exit status


CMakeOutput.log
The target system is: PICO - - cortex-m0plus
The host system is: Linux - 5.10.17-v7l+ - armv7l
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /usr/bin/arm-none-eabi-gcc
Build flags:
Id flags: -c

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.o"

The C compiler identification is GNU, found in "/home/pi/pico/b-em/pico-build/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.o"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /usr/bin/arm-none-eabi-g++
Build flags:
Id flags: -c

The output was:
0


Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.o"

The CXX compiler identification is GNU, found in "/home/pi/pico/b-em/pico-build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.o"

Checking whether the ASM compiler is GNU using "--version" matched "(GNU assembler)|(GCC)|(Free Software Foundation)":
arm-none-eabi-gcc (15:7-2018-q2-6) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
kilog
Posts: 51
Joined: Mon Jul 13, 2020 2:58 am
Contact:

Re: RP2040/Pico beeb emulator

Post by kilog »

Might be a version of SDK thing...

in any case the issue is with beeb_360 and master_360 i think

I would just build

make beeb beeb_10808p master master_1080p
Silversmurfer
Posts: 4
Joined: Mon May 24, 2021 5:27 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by Silversmurfer »

yep it's something in the SDK - works with SDK 1.1.0 - fails with 1.1.1 or 1.1.2
kilog
Posts: 51
Joined: Mon Jul 13, 2020 2:58 am
Contact:

Re: RP2040/Pico beeb emulator

Post by kilog »

there are a lot of moving parts - i think it should work with the "develop" branch of pico_sdk, but there will be SDK1.2.0 very shortly.
User avatar
sixxdog_uk
Posts: 284
Joined: Mon Feb 29, 2016 11:06 am
Contact:

Re: RP2040/Pico beeb emulator

Post by sixxdog_uk »

kilog wrote: Sun Mar 07, 2021 11:12 pm Figured i should split this off the Pi version thread.

Code is here https://github.com/kilograham/b-em

just updated with support for 1080p 50hz VGA output which some monitors may like better than 1280x1024 50hz
This is a great project , am I right in saying this is the same ‘bare metal’ project I’ve seen video clips of on you tube?

I’d love to build one of these , in your honest opinion how easy would it be for a pi novice to achieve this?

Again huge kudos for a great project 👍👍👍
kilog
Posts: 51
Joined: Mon Jul 13, 2020 2:58 am
Contact:

Re: RP2040/Pico beeb emulator

Post by kilog »

You can use one of these https://shop.pimoroni.com/products/pimo ... -demo-base

Also, i made one with 3 bit video hooked up by one red/green/blue wire only and a few resistors and that works too... you currently need I2s for the audio, though I plan to add 8 bit PWM support back to the audio library which is pretty trivial) which would let you get away with just a resistor and a capacitor
noggin
Posts: 40
Joined: Mon Jul 17, 2017 4:06 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by noggin »

kilog wrote: Tue Jun 22, 2021 1:58 am You can use one of these https://shop.pimoroni.com/products/pimo ... -demo-base

Also, i made one with 3 bit video hooked up by one red/green/blue wire only and a few resistors and that works too... you currently need I2s for the audio, though I plan to add 8 bit PWM support back to the audio library which is pretty trivial) which would let you get away with just a resistor and a capacitor
Would that work with one of the Pimoroni Tiny 2040s? Is it buildable from current code?
kilog
Posts: 51
Joined: Mon Jul 13, 2020 2:58 am
Contact:

Re: RP2040/Pico beeb emulator

Post by kilog »

should be fine- i'm pretty sure things build ok at the moment with the latest pico-sdk / pico-extras

I think setting PICO_BOARD=tiny_vga_i2s

will build you correctly for video on GPIO 2,3,4 I2S on 5,6,7
noggin
Posts: 40
Joined: Mon Jul 17, 2017 4:06 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by noggin »

kilog wrote: Mon Jul 12, 2021 2:32 pm should be fine- i'm pretty sure things build ok at the moment with the latest pico-sdk / pico-extras

I think setting PICO_BOARD=tiny_vga_i2s

will build you correctly for video on GPIO 2,3,4 I2S on 5,6,7
Belated thanks for this - will give it a go!
User avatar
lushprojects
Posts: 148
Joined: Mon Jan 18, 2021 4:02 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by lushprojects »

Thanks for some amazing work putting this together. I am just trying on my new Xmas present Pi Pico with the Pimoroni VGA adaptoer.

Without the USB keyboard it works fine. However, when I try and make with the USB keyboard support added I get this error:

Code: Select all

/home/pi/b-em/src/pico/usb_host_hid/usb_host_hid.c:31:10: fatal error: bsp/board.h: No such file or directory
 #include "bsp/board.h"
          ^~~~~~~~~~~~~
Possibly a missing dependency or bad path somewhere? There doesn't seem to be a board.h file in the listed dependencies, so I am guessing the former. Any advice? Thanks.
User avatar
lushprojects
Posts: 148
Joined: Mon Jan 18, 2021 4:02 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by lushprojects »

lushprojects wrote: Mon Dec 27, 2021 11:33 am Thanks for some amazing work putting this together. I am just trying on my new Xmas present Pi Pico with the Pimoroni VGA adaptoer.

Without the USB keyboard it works fine. However, when I try and make with the USB keyboard support added I get this error:

Code: Select all

/home/pi/b-em/src/pico/usb_host_hid/usb_host_hid.c:31:10: fatal error: bsp/board.h: No such file or directory
 #include "bsp/board.h"
          ^~~~~~~~~~~~~
Possibly a missing dependency or bad path somewhere? There doesn't seem to be a board.h file in the listed dependencies, so I am guessing the former. Any advice? Thanks.
On further examination, I believe the missing library is tinyusb, but I am not sure how to configure and incorporate it in this project.
User avatar
lushprojects
Posts: 148
Joined: Mon Jan 18, 2021 4:02 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by lushprojects »

lushprojects wrote: Sat Jan 15, 2022 5:52 pm On further examination, I believe the missing library is tinyusb, but I am not sure how to configure and incorporate it in this project.
Progress of a kind: it seems you need to manually clone tinyusb in to pico-sdk/lib. Then the make finds the tinyusb install. However, there seems to be a version incompatibility problem due to changes in the API. I tried stepping tinyusb back to commit e0aa405 which might be the version this was originally built against, but even that still has problems.
User avatar
lushprojects
Posts: 148
Joined: Mon Jan 18, 2021 4:02 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by lushprojects »

I have updated the code to use the latest tinyusb release and it is working on my Pico. I will do some more tweaks and upload to a GitHub fork in a few days.
User avatar
lushprojects
Posts: 148
Joined: Mon Jan 18, 2021 4:02 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by lushprojects »

I've added an experimental verison that builds against the new tinyusb API:
https://github.com/sharpie7/b-em/tree/tinyusb-new-api

Unforunately it has some problems that I can't seem to resolve, though it does basically work.
kilog
Posts: 51
Joined: Mon Jul 13, 2020 2:58 am
Contact:

Re: RP2040/Pico beeb emulator

Post by kilog »

Nice; there is this branch here https://github.com/liamfraser/tinyusb/c ... kbd-rebase which has some in progress RP2040 host mode fixes.

I haven't had a chance to try it myself with the emu, but it is working OK for me in another project.
User avatar
lushprojects
Posts: 148
Joined: Mon Jan 18, 2021 4:02 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by lushprojects »

kilog wrote: Mon Feb 14, 2022 3:13 am Nice; there is this branch here https://github.com/liamfraser/tinyusb/c ... kbd-rebase which has some in progress RP2040 host mode fixes.

I haven't had a chance to try it myself with the emu, but it is working OK for me in another project.
Thanks - looks interesting. I am doing some updates to the MISTer FPGA emulator at the moment, but once I've finished that I'll circle back and see if it changes anything in my fork.
User avatar
lushprojects
Posts: 148
Joined: Mon Jan 18, 2021 4:02 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by lushprojects »

kilog wrote: Mon Feb 14, 2022 3:13 am Nice; there is this branch here https://github.com/liamfraser/tinyusb/c ... kbd-rebase which has some in progress RP2040 host mode fixes.
I believe that these changes have now been folded into the master branch of tinyusb.

I rebuilt the project today using the latest tinyusb and the USB keyboard now seems to be working fine. See here:
https://github.com/sharpie7/b-em/tree/tinyusb-new-api
billbates
Posts: 5
Joined: Mon Mar 20, 2023 6:05 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by billbates »

I know this is an old topic but is there going to be any further updates for the pico b-em ?
I'm using sharpie7's build which is the only build that has working USB keyboard support, well almost apart from some screen glitches when you press a few keys on the keyboard. Most of the video resolutions are also a little flakey with standard monitor resolutions and timings. I don't understand why the USB HID device can interfere with the video and cause the monitor to lose sync randomly ?
User avatar
lushprojects
Posts: 148
Joined: Mon Jan 18, 2021 4:02 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by lushprojects »

As I understand it, most of the work for both the USB and the video out is being done in the CPU and even with the overclock it doesn't have a enough capacity to keep all the plates spinning at the proper speed once things get busy.

As far as I know, nobody has picked up my mods for USB keyboard support, though the original author is aware of them.

Overall, my feeling was that there was a lot of work to make this a good stand-alone emulator, and I wasn't even sure it was possible so having got the USB working I decide not to put more effort into it. It's a very interesting project though.
billbates
Posts: 5
Joined: Mon Mar 20, 2023 6:05 pm
Contact:

Re: RP2040/Pico beeb emulator

Post by billbates »

I've gone through some of the code myself but it all seems patched together which makes it much more difficult to work on. I think if the code could be spilt between cores then the pico would be more than capable of "spinning the plates" so to speak. I noticed in this thread, that someone posted a fix for the USB and video corruption issue which involved changing the src/rp2_common/pico_scanvideo_dpi/scanvideo.c in pico_extras with a fixed int delay0. That worked pretty well but the video resolution appeared more stretched.

I've using the PicoVGA library from this excellent site: https://breatharian.eu/hw/picovga/index_en.html
The library is also forked here using the Pi Pico SDK with more features and updates: https://github.com/codaris/picovga-cmake
If all the video code could be ported to use the PicoVGA library then that may fix alot of issues with performance as the library is very lightweight and is optimized for 8-bit graphics performance.

For what it's worth I certainly appreciate your effort to improve the functionality of the USB side of things.
Post Reply

Return to “8-bit acorn emulators”