Closed DFL1973 closed 11 months ago
Compiling from source is not really that hard, and the key thing for me is that if you have any issues, its significantly easier to troubleshoot and try and resolve any problem you might have if I know you have the ability to compile from the source. If you can't compile from source then we end up in this guessing game where I try something, compile a new firmware, you try it (probably in a different timezone), a day later you tell me what happened and this goes back and forth for quite some time. Its far easier to say "Lets try changing this parameter in the source to a few different values and you can compile the source and do that yourself and see how it goes".
I had someone reach out to me recently on the msx rom/floppy project and I ended up looking at current ways of compiling the source (since all my rom/floppy projects are compiled the same way) and it's probably far easier today to compile this stuff than years ago. I'll assume you are on windows or Mac as its far easier to compile directly on linux.
One of the easier options is to use docker (install docker desktop first on Windows or Mac), then get the STM32F4DISCOVERY board firmware package from st.com. This is called STSW-STM32068 (you can probably search for it on st.com). You should end up with a file called en.stsw-stm32068.zip with an MD5 sum of 6063f18dff8b5f1ddfafa77d1ab72ad9. Then you do something like this
mkdir work
cd work
# Get the en.stsw-stm32068.zip file into the the current directory (ie. the work directory that was just created)
docker run -v .:/work -it debian:bullseye-slim
apt update
apt install -y gcc-arm-none-eabi git unzip make
cd /work
git clone https://github.com/kernelcrash/dragon-rom-and-floppy-emulator.git
unzip en.stsw-stm32068.zip
cd dragon-rom-and-floppy-emulator
make
## The make output should look like the following (I've abbreviated it)
arm-none-eabi-gcc -g -O2 -Wall -Tstm32_flash.ld -ffunction-sections -fdata-sections -fomit-frame-pointer
...
arm-none-eabi-objcopy -O ihex dragon-rom-and-floppy-emulator.elf dragon-rom-and-floppy-emulator.hex
arm-none-eabi-objcopy -O binary dragon-rom-and-floppy-emulator.elf dragon-rom-and-floppy-emulator.bin
So if you type 'exit' you get back to Windows or Mac and you should see the dragon-rom-and-floppy-emulator directory. Inside it will be all the source files and a dragon-rom-and-floppy-emulator.hex and dragon-rom-and-floppy-emulator.bin. They are essentially the same firmware file (just in different formats). I have an example script called transfer.sh which is designed for a linux machine to flash the firmware via USB. It's a one line command on linux. I am not too sure what the options are on Windows and Mac. I know ST have some windows tools for flashing firmwares to STM32 chips , but I honestly don't know much about those tools (but if you find one and it lets you load the hex or bin file then in theory it should work).
Another quite 'easy' option is if you have a Raspberry Pi with the Raspberry Pi OS on it (which is basically just Debian linux). I am mentioning this as a lot of people seem to have a Raspberry Pi in a drawer somewhere. You can potentially do this in a terminal on the Raspberry Pi
sudo apt update
## The next command may say certain packages were already installed. That is fine.
sudo apt install -y gcc-arm-none-eabi git unzip make dfu-util
## You now need that same en.stsw-stm32068.zip file from st.com. Put it in the current directory.
unzip en.stsw-stm32068.zip
cd dragon-rom-and-floppy-emulator
make
## The make output should look like the following (I've abbreviated it)
arm-none-eabi-gcc -g -O2 -Wall -Tstm32_flash.ld -ffunction-sections -fdata-sections -fomit-frame-pointer
...
arm-none-eabi-objcopy -O ihex dragon-rom-and-floppy-emulator.elf dragon-rom-and-floppy-emulator.hex
arm-none-eabi-objcopy -O binary dragon-rom-and-floppy-emulator.elf dragon-rom-and-floppy-emulator.bin
Again, you end up with the dragon-rom-and-floppy-emulator.hex and dragon-rom-and-floppy-emulator.bin file which is 'the firmware' but in two different file formats. On the Raspberry Pi you can use that transfer.sh script to try to transfer the firmware. If you check the README.md it mentions that you need to set the BOOT0 and BOOT1 pins appropriately then plug the stm32f407 board in with a usb cable to the raspberry pi (obviously don't have this plugging in to the Dragon or Coco at the same time). Then if you type lsusb you should hopefully see a line with 'STMicroelectronics STM Device in DFU Mode' . If it doesn't then fiddle with the BOOT0 or BOOT1 pins until it does and then enter
./transfer.sh
Then unplug it and remove the BOOT0 or BOOT1 jumper and the board should be OK to test with.
Another option is to download a Debian live USB. I haven't actually tried this before posting, but these linux live USB things are quite impressive nowadays and you can actually boot up your PC off a USB stick that has a full desktop and allows you to install packages and run a web browser etc all without having to install anything on your hard drive. Perhaps the trickiest thing for anyone who has not tried one of these things is 'getting in the BIOS to turn off secure Boot' before you try to boot it by pressing F12 a lot.
So that should give you some options for getting the firmware on the stm32f407 board. Technically the firmware should auto load the first file you have copied in to the dragon or tandy folder and load it (I would put a simple ROM in to try out first). If you want the menu system (KCDFS/KCCFS) then you need to assemble the 6809 source for that. You need a cross assembler called lwtools for that. It's not too hard to install either. Here's how you might assemble the KCDFS/KCCFS thing using docker.
mkdir work2
cd work2
docker run -v .:/work2 -it debian:bullseye-slim
apt update
apt install -y git make gcc-9
cd /work2
git clone https://github.com/jmatzen/LWTools.git
cd LWTools
CC="gcc-9" make
make install
cd /work2
git clone https://github.com/kernelcrash/dragon-rom-and-floppy-emulator.git
cd dragon-rom-and-floppy-emulator/kcdfs
./build.sh
Type 'exit' to exit the docker container and then you should see the dragon-rom-and-floppy-emulator folder. Inside this copy of dragon-rom-and-floppy-emulator look at the kcdfs directory and you should see the menu.rom file. It should be 8192 bytes. You just need to put that in the root of your SD card. The firmware on the stm32f407 board should then look for the menu.rom on the card at boot time ... and your Dragon of Coco should boot the menu.rom first.
See how you go.
Hey, thanks for the help, I really appreciate it.
After your fully detailed explanation, I successfully compiled the project and got the files.
Many thanks for sharing this, it works really well!
Please, make a release with the compiled files. It will be a HUGE help to those that don't have the dev software installed
Thanks for sharing!