Raspberry Pico C++ dev with Mingw

How to prepare your environment in Windows operating system and compile your blink program written in C.

Prepare compiler environment

install MSYS2 from https://www.msys2.org/

configure windows terminal

  "profiles": {
   "list": [
                "guid": "{17da3cac-b318-431e-8a3e-7fcdefe6d114}",
                "name": "MINGW64 / MSYS2",
                "commandline": "S:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw64",
                //"startingDirectory": "C:/msys64/home/%USERNAME%",
                "startingDirectory": "W:/work",
                "icon": "S:/msys64/mingw64.ico",
                // "fontFace": "IBM 3270",
                // "fontWeight": "normal",
                "fontSize": 12,
                "colorScheme": "GitBash"

using x86_64 version, inside shell, install packages

pacman -Syuu
pacman -S pacman -S mingw-w64-x86_64-make
pacman -S mingw-w64-x86_64-arm-none-eabi-gcc
pacman -S mingw-w64-x86_64-cmake

Download and compile source code

git clone -b master "https://github.com/raspberrypi/pico-sdk.git"
cd pico-sdk
git submodule update --init

export PICO_SDK_PATH=/w/work/rbpico/win/pico-sdk

git clone -b master "https://github.com/raspberrypi/pico-examples.git"
cd pico-examples/
git submodule update --init

mkdir build
cd build
cmake ../ -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug

First, install SDK into Widows WSL2

wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh

export SKIP_VSCODE=1
export SKIP_UART=1
export OUTDIR=/mnt/w/work/rbpico


PS: the list of msys2 package can be browsed from: https://packages.msys2.org/package/

REF: https://stackoverflow.com/questions/33816778/cmake-nmake-makefiles-generator-fails-to-compile/38131177

Apple II Slot system

Apple II Slot System is the powerful and flexible system which every Apple II and Apple ][+ has.

Apple II has eight almost identical 50-pin expansion slots, named from SLOT0 up to SLOT7. They are almost identical because SLOT0 and SLOT7 are a little different from others.

SLOT0 is special because It DOES NOT HAVE the 256 bytes spaces (/IOSEL) as all others slots have. It is used typically for the firmware card or the 16 KB Apple II Language Card.

SLOT7 is special because it has the same signals all other slots have plus two exclusive signals. It is used for Video related boards, like PAL Encoder Card in Apple II EuroPlus. These two additional signals are: (1) on pin 35 a signal of 3.5Mhz COLOR REFerence from video generator; (2) on pin 19 the SYNC signal from video generator.

All I/O is memory mapped (6502 does not have exclusive I/O oriented instructions like z80 has). In Apple II architecture, a window of 4KB is reserved for I/O with addresses between $C000 and $CFFF, this memory range is called I/O space.

The 4KB I/O space is divided in two halves of 2KB each: (1) space for 8 slots I/O, addresses from $C000 to $C7FF; (2) common area for all slots, addresses from $C800 to $CFFF. In this first half, each slot has 16 bytes for register use plus 256 bytes for address use, in this space there is also the soft switches; The second half is shared among all slots, used when card’s firmware is big and the 256 bytes from slot exclusively are insufficient.

(128 bytes)
$C000..$C07F = Soft switches 

(16 bytes each region)
$C080..$C08F = Slot 0 /DEVSEL
$C090..$C09F = Slot 1 /DEVSEL
$C0A0..$C0AF = Slot 2 /DEVSEL
$C0B0..$C0BF = Slot 3 /DEVSEL
$C0C0..$C0CF = Slot 4 /DEVSEL
$C0D0..$C0DF = Slot 5 /DEVSEL
$C0E0..$C0EF = Slot 6 /DEVSEL
$C0F0..$C0FF = Slot 7 /DEVSEL

(256 bytes each region)
$C100..$C1FF = Slot 1 /IOSEL
$C200..$C2FF = Slot 2 /IOSEL
$C300..$C3FF = Slot 3 /IOSEL
$C400..$C4FF = Slot 4 /IOSEL
$C500..$C5FF = Slot 5 /IOSEL
$C600..$C6FF = Slot 6 /IOSEL
$C700..$C7FF = Slot 7 /IOSEL

(2048 bytes)
$C800..$CFFF = Common area (2KB ROM)

The common area for all slots has 2KB, in address range from $C800 to $CFFF. This area is shared among all slots. Whenever some slot wants to use data from its ROM mapped into this area is must access (read or write?) address $CFFF to deselect all eventually ROM that could be mapped into this area; after this the correct ROM should be selected. In summary, the protocol is simple: wherever somebody access address $CFFF, all cards that has a ROM mapped in common area must deselect it (inhibit its output).

MSX ROM Cartridge

How to wire a simple ROM cartridge to connect to your MSX Computer

How to wire a simple ROM cartridge to connect to your MSX Computer.

From MSX BUS, each physical slot has a signal called /SLTSL, activate in low, which signals when CPU may want access physically that slot. Note that this signal do not specify if it is a memory read, memory write or even a memory refresh cycle (?).

Another interesting signals are: /CS1, /CS2, /CS12, activate in low, which signals when CPU want to read that memory address range. In this case, It’s for sure a memory read! BUT every slot will receive this signal, so you can not tell if this read attempt is for you or not.

Signal /CS1 activates when memory read address is between &H4000 and &H7FFF; signal /CS2 activates when memory read address is between &H8000 and &HBFFF; and /CS12 when address is between &H4000 and &HBFFF.

So to connect a simple ROM you’ll use two signals: /SLTSL to chip enable and /CS1 or /CS2 or /CS12 to output enable.

IMPORTANT: DO NOT use /SLTSL to output enable because it can be asserted in a memory write cycle, which will lead to a bus contention.


16KB cartridge (PAGE1, addresses &H4000..&H7FFF)

  • MSX /CS1 -> ROM /OE
  • MSX A15 -> ROM A14
    • or: GND -> ROM A14
  • MSX GND -> ROM A15

16KB cartridge (PAGE2, addresses &H8000..&HBFFF)

  • MSX /CS2 -> ROM /OE
  • MSX A14 -> ROM A14
    • or: GND -> ROM A14
  • MSX GND -> ROM A15

32KB cartridge (PAGES 1 and 2, addresses &H4000..&HBFFF)

  • MSX /CS12 -> ROM /OE
  • MSX A15 -> ROM A14
  • MSX GND -> ROM A15

64KB cartridge (all pages maybe not useful but it’s possible)

  • MSX /RD -> ROM /OE
  • MSX A14 -> ROM A14
  • MSX A15 -> ROM A15

REF: https://retrocomputing.stackexchange.com/questions/12701/what-is-the-circuit-for-a-16k-or-32k-msx-computer-cartridge