From e924ad5d19f84d1a5de1890507f07bc17240e484 Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 1 Nov 2023 18:59:01 +0100 Subject: [PATCH 1/5] Update Acknowledgements [ci skip] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8070e57..7eae3e5 100644 --- a/README.md +++ b/README.md @@ -88,3 +88,4 @@ This project stands on the shoulders of giants. Special thanks to: * [dcoredump](https://github.com/dcoredump) for https://codeberg.org/dcoredump/Synth_Dexed, a port of Dexed for embedded systems * [rsta2](https://github.com/rsta2) for https://github.com/rsta2/circle, the library to run code on bare metal Raspberry Pi (without a Linux kernel or operating system) and for the bulk of the MiniDexed code * [smuehlst](https://github.com/smuehlst) for https://github.com/smuehlst/circle-stdlib, a version with Standard C and C++ library support +* [Banana71](https://github.com/Banana71) for the sound design of the performances shipped with MiniDexed From d9dc84d583e92156a86bbd97f54911f26a2a8014 Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 1 Nov 2023 19:00:24 +0100 Subject: [PATCH 2/5] Add Synth Geekery [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7eae3e5..2fcd8fc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![minidexed](https://user-images.githubusercontent.com/2480569/161813414-bb156a1c-efec-44c0-802a-8926412a08e0.jpg) -MiniDexed is a FM synthesizer closely modeled on the famous DX7 by a well-known Japanese manufacturer running on a bare metal Raspberry Pi (without a Linux kernel or operating system). On Raspberry Pi 2 and larger, it can run 8 tone generators, not unlike the TX816/TX802 (8 DX7 instances without the keyboard in one box). [Featured by HACKADAY](https://hackaday.com/2022/04/19/bare-metal-gives-this-pi-some-classic-synths/) and [adafruit](https://blog.adafruit.com/2022/04/25/free-yamaha-dx7-synth-emulator-on-a-raspberry-pi/). +MiniDexed is a FM synthesizer closely modeled on the famous DX7 by a well-known Japanese manufacturer running on a bare metal Raspberry Pi (without a Linux kernel or operating system). On Raspberry Pi 2 and larger, it can run 8 tone generators, not unlike the TX816/TX802 (8 DX7 instances without the keyboard in one box). [Featured by HACKADAY](https://hackaday.com/2022/04/19/bare-metal-gives-this-pi-some-classic-synths/), [adafruit](https://blog.adafruit.com/2022/04/25/free-yamaha-dx7-synth-emulator-on-a-raspberry-pi/), and [Synth Geekery](https://www.youtube.com/watch?v=TDSy5nnm0jA). ## Features From 157cf955b894abe83ad00de616a9dd1688e16da4 Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 1 Nov 2023 21:10:06 +0100 Subject: [PATCH 3/5] Mention editors and MiniDexedLibrarian [ci skip] --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2fcd8fc..bbd07dc 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ Video about this project by [Floyd Steinberg](https://www.youtube.com/watch?v=Z3 * If the system seems to become unresponsive after a few seconds, remove `usbspeed=full` from `cmdline.txt` and repeat ([details](https://github.com/probonopd/MiniDexed/issues/39)) * Optionally, put voices in `.syx` files onto the SD card (e.g., using `getsysex.sh`) * See the Wiki for [Menu](https://github.com/probonopd/MiniDexed/wiki/Menu) operation +* For voice programming, use any DX series editor (using MIDI sysex), including Dexed +* For library management, use the dedicated [MiniDexedLibrarian](https://github.com/BobanSpasic/MiniDexedLibrarian) software * If something is unclear or does not work, don't hesitate to [ask](https://github.com/probonopd/MiniDexed/discussions/)! ## Pinout @@ -89,3 +91,4 @@ This project stands on the shoulders of giants. Special thanks to: * [rsta2](https://github.com/rsta2) for https://github.com/rsta2/circle, the library to run code on bare metal Raspberry Pi (without a Linux kernel or operating system) and for the bulk of the MiniDexed code * [smuehlst](https://github.com/smuehlst) for https://github.com/smuehlst/circle-stdlib, a version with Standard C and C++ library support * [Banana71](https://github.com/Banana71) for the sound design of the performances shipped with MiniDexed +* [BobanSpasic] for the [MiniDexedLibrarian](https://github.com/BobanSpasic/MiniDexedLibrarian) software From c5c4e13814273e1906b4a2c267c13d9113812ad4 Mon Sep 17 00:00:00 2001 From: probonopd Date: Wed, 1 Nov 2023 21:10:48 +0100 Subject: [PATCH 4/5] Update README.md [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bbd07dc..955e279 100644 --- a/README.md +++ b/README.md @@ -91,4 +91,4 @@ This project stands on the shoulders of giants. Special thanks to: * [rsta2](https://github.com/rsta2) for https://github.com/rsta2/circle, the library to run code on bare metal Raspberry Pi (without a Linux kernel or operating system) and for the bulk of the MiniDexed code * [smuehlst](https://github.com/smuehlst) for https://github.com/smuehlst/circle-stdlib, a version with Standard C and C++ library support * [Banana71](https://github.com/Banana71) for the sound design of the performances shipped with MiniDexed -* [BobanSpasic] for the [MiniDexedLibrarian](https://github.com/BobanSpasic/MiniDexedLibrarian) software +* [BobanSpasic](https://github.com/BobanSpasic) for the [MiniDexedLibrarian](https://github.com/BobanSpasic/MiniDexedLibrarian) software From 258a456d40c5f2c89cac924604e8c5bcade8b7ee Mon Sep 17 00:00:00 2001 From: Kevin <68612569+diyelectromusic@users.noreply.github.com> Date: Fri, 24 Nov 2023 20:00:49 +0000 Subject: [PATCH 5/5] Add USB Gadget Device support (#567) * Initial attempt to include USB Gadget Mode as a configuration option. Note: Also requires a move to the latest release of circle. * Set "official" (as allocated from pid.codes) USB vendor and device ID for MiniDexed --- USBID.sh | 2 ++ build.sh | 9 +++++++++ src/Rules.mk | 1 + src/circle_stdlib_app.h | 15 +-------------- src/config.cpp | 7 +++++++ src/config.h | 5 +++++ src/kernel.cpp | 20 +++++++++++++++++++- src/kernel.h | 2 ++ src/minidexed.cpp | 9 +++++++++ submod.sh | 15 ++++++++++++--- 10 files changed, 67 insertions(+), 18 deletions(-) create mode 100644 USBID.sh diff --git a/USBID.sh b/USBID.sh new file mode 100644 index 0000000..593df3a --- /dev/null +++ b/USBID.sh @@ -0,0 +1,2 @@ +USB_VID=0x1209 +USB_DID=0xF043 diff --git a/build.sh b/build.sh index b1b3246..9e8fc7a 100755 --- a/build.sh +++ b/build.sh @@ -20,6 +20,15 @@ if [ "${RPI}" -gt "1" ]; then OPTIONS="${OPTIONS} -o ARM_ALLOW_MULTI_CORE" fi +# USB Vendor and Device ID for use with USB Gadget Mode +source USBID.sh +if [ "${USB_VID}" ] ; then + OPTIONS="${OPTIONS} -o USB_GADGET_VENDOR_ID=${USB_VID}" +fi +if [ "${USB_DID}" ] ; then + OPTIONS="${OPTIONS} -o USB_GADGET_DEVICE_ID=${USB_DID}" +fi + # Build circle-stdlib library cd circle-stdlib/ make mrproper || true diff --git a/src/Rules.mk b/src/Rules.mk index d466b74..2ebc132 100644 --- a/src/Rules.mk +++ b/src/Rules.mk @@ -22,6 +22,7 @@ LIBS += \ $(CIRCLEHOME)/addon/Properties/libproperties.a \ $(CIRCLEHOME)/addon/SDCard/libsdcard.a \ $(CIRCLEHOME)/lib/usb/libusb.a \ + $(CIRCLEHOME)/lib/usb/gadget/libusbgadget.a \ $(CIRCLEHOME)/lib/input/libinput.a \ $(CIRCLEHOME)/lib/sound/libsound.a \ $(CIRCLEHOME)/addon/fatfs/libfatfs.a \ diff --git a/src/circle_stdlib_app.h b/src/circle_stdlib_app.h index 3c38f0d..8a69c82 100644 --- a/src/circle_stdlib_app.h +++ b/src/circle_stdlib_app.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -160,7 +159,6 @@ public: const char *pPartitionName = CSTDLIBAPP_DEFAULT_PARTITION) : CStdlibAppScreen (kernel), mpPartitionName (pPartitionName), - mUSBHCI (&mInterrupt, &mTimer, TRUE), mEMMC (&mInterrupt, &mTimer, &mActLED), #if !defined(__aarch64__) || !defined(LEAVE_QEMU_ON_HALT) //mConsole (&mScreen, TRUE) @@ -199,16 +197,6 @@ public: return false; } -#if !defined(__aarch64__) || !defined(LEAVE_QEMU_ON_HALT) - // The USB driver is not supported under 64-bit QEMU, so - // the initialization must be skipped in this case, or an - // exit happens here under 64-bit QEMU. - if (!mUSBHCI.Initialize ()) - { - return false; - } -#endif - if (!mConsole.Initialize ()) { return false; @@ -223,7 +211,7 @@ public: return true; } - + virtual void Cleanup (void) { f_mount(0, "", 0); @@ -232,7 +220,6 @@ public: } protected: - CUSBHCIDevice mUSBHCI; CEMMCDevice mEMMC; FATFS mFileSystem; CConsole mConsole; diff --git a/src/config.cpp b/src/config.cpp index d06a84a..526d8ad 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -35,6 +35,8 @@ CConfig::~CConfig (void) void CConfig::Load (void) { m_Properties.Load (); + + m_bUSBGadgetMode = m_Properties.GetNumber ("USBGadget", 0) != 0; m_SoundDevice = m_Properties.GetString ("SoundDevice", "pwm"); @@ -152,6 +154,11 @@ void CConfig::Load (void) m_bPerformanceSelectChannel = m_Properties.GetNumber ("PerformanceSelectChannel", 0); } +bool CConfig::GetUSBGadgetMode (void) const +{ + return m_bUSBGadgetMode; +} + const char *CConfig::GetSoundDevice (void) const { return m_SoundDevice.c_str (); diff --git a/src/config.h b/src/config.h index c088461..f83c177 100644 --- a/src/config.h +++ b/src/config.h @@ -62,6 +62,9 @@ public: ~CConfig (void); void Load (void); + + // USB Mode + bool GetUSBGadgetMode (void) const; // true if in USB gadget mode // Sound device const char *GetSoundDevice (void) const; @@ -167,6 +170,8 @@ public: private: CPropertiesFatFsFile m_Properties; + + bool m_bUSBGadgetMode; std::string m_SoundDevice; unsigned m_nSampleRate; diff --git a/src/kernel.cpp b/src/kernel.cpp index 1617845..e7a3738 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -21,6 +21,8 @@ #include #include #include +#include +#include LOGMODULE ("kernel"); @@ -63,7 +65,23 @@ bool CKernel::Initialize (void) } m_Config.Load (); + + if (m_Config.GetUSBGadgetMode()) + { + // Run the USB stack in USB Gadget (device) mode + m_pUSB = new CUSBMIDIGadget (&mInterrupt); + } + else + { + // Run the USB stack in USB Host (default) mode + m_pUSB = new CUSBHCIDevice (&mInterrupt, &mTimer, TRUE); + } + if (!m_pUSB->Initialize ()) + { + return FALSE; + } + m_pDexed = new CMiniDexed (&m_Config, &mInterrupt, &m_GPIOManager, &m_I2CMaster, &mFileSystem); assert (m_pDexed); @@ -82,7 +100,7 @@ CStdlibApp::TShutdownMode CKernel::Run (void) while (42 == 42) { - boolean bUpdated = mUSBHCI.UpdatePlugAndPlay (); + boolean bUpdated = m_pUSB->UpdatePlugAndPlay (); m_pDexed->Process(bUpdated); diff --git a/src/kernel.h b/src/kernel.h index de9a5f0..7d2f346 100644 --- a/src/kernel.h +++ b/src/kernel.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "config.h" #include "minidexed.h" @@ -54,6 +55,7 @@ private: CGPIOManager m_GPIOManager; CI2CMaster m_I2CMaster; CMiniDexed *m_pDexed; + CUSBController *m_pUSB; static CKernel *s_pThis; }; diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 1ddf250..71b7247 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -97,6 +97,15 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, m_pTG[i]->setEngineType(pConfig->GetEngineType ()); m_pTG[i]->activate (); } + + if (pConfig->GetUSBGadgetMode()) + { + LOGNOTE ("USB In Gadget (Device) Mode"); + } + else + { + LOGNOTE ("USB In Host Mode"); + } for (unsigned i = 0; i < CConfig::MaxUSBMIDIDevices; i++) { diff --git a/submod.sh b/submod.sh index dcdf2af..2e24228 100755 --- a/submod.sh +++ b/submod.sh @@ -1,15 +1,24 @@ #!/bin/bash set -ex +# +# Update top-level modules as a baseline git submodule update --init --recursive +# +# Use fixed master branch of circle-stdlib then re-update cd circle-stdlib/ -git checkout e318f89 # Needed to support Circle develop? +git checkout 695ab4a +git submodule update --init --recursive cd - +# +# Optional update submodules explicitly cd circle-stdlib/libs/circle -git checkout ec09d7e # develop +git checkout fe09c4b cd - cd circle-stdlib/libs/circle-newlib -git checkout 48bf91d # needed for circle ec09d7e +#git checkout develop cd - +# +# Use fixed master branch of Synth_Dexed cd Synth_Dexed/ git checkout c9f5274 cd -