diff --git a/BUILD.txt b/BUILD.txt new file mode 100644 index 0000000..ca9ed9b --- /dev/null +++ b/BUILD.txt @@ -0,0 +1,77 @@ +Building instructions: + +1) Raspberry Pi with ZUMSpot Pi: + +* Download latest Raspbian image and install to a micro SD +- See: https://www.raspberrypi.org/documentation/installation/installing-images/ +- Configure your SD before booting. Useful article: + https://styxit.com/2017/03/14/headless-raspberry-setup.html +- Boot your Raspberry Pi +- Run raspi-config and configure according your preferences: +sudo raspi-config +(at least expand filesystem and change default password. It's a good idea to enable "Wait +for Network at Boot" and disable Desktop GUI if you don't plan to use it) + +* Enable serial port /dev/ttyAMA0 (Raspberry Pi 3 or Pi Zero W only): +- Edit /boot/cmdline.txt +sudo nano /boot/cmdline.txt +(remove the text: console=serial0,115200) + +- Disable services: +sudo systemctl disable serial-getty@ttyAMA0.service +sudo systemctl disable bluetooth.service + +- Edit /boot/config.txt +sudo nano /boot/config.txt +(add the following lines): +enable_uart=1 +dtoverlay=pi3-disable-bt + +- Reboot the RPi: +sudo reboot + +* Build de firmware and upload to ZUMSpot: +cd ~ +- Install the necessary software tools: +sudo apt-get update +sudo apt-get install gcc-arm-none-eabi gdb-arm-none-eabi +git clone https://git.code.sf.net/p/stm32flash/code stm32flash +cd stm32flash +make +sudo make install +cd ~ + +- Download the sources: +git clone https://github.com/juribeparada/MMDVM_HS +cd MMDVM_HS/ +git clone https://github.com/juribeparada/STM32F10X_Lib + +- Edit Config.h +nano Config.h +(and enable): +#define PI_HAT_7021_REV_03 +#define ENABLE_ADF7021 +#define ADF7021_N_VER (only if your board uses ADF7021N) +#define BIDIR_DATA_PIN +#define ADF7021_14_7456 +#define STM32_USART1_HOST +#define ENABLE_SCAN_MODE + +- Build the firmware: +make + +- Upload the firmware to ZUMSpot Pi board: +sudo make zumspot-pi + +* Install MMDVMHost: +cd ~ +git clone https://github.com/g4klx/MMDVMHost/ +cd MMDVMHost/ +make + +- Edit MMDVM.ini according your preferences +nano MMDVM.ini +(use Port=/dev/ttyAMA0 in [Modem]) + +- Execute MMDVMHost: +./MMDVMHost MMDVM.ini diff --git a/DMRDMOTX.cpp b/DMRDMOTX.cpp index ccf24a2..c4426a0 100644 --- a/DMRDMOTX.cpp +++ b/DMRDMOTX.cpp @@ -22,18 +22,6 @@ #include "Config.h" #include "Globals.h" -#include "DMRSlotType.h" - -// The PR FILL and Data Sync pattern. -const uint8_t IDLE_DATA[] = - {0x53U, 0xC2U, 0x5EU, 0xABU, 0xA8U, 0x67U, 0x1DU, 0xC7U, 0x38U, 0x3BU, 0xD9U, - 0x36U, 0x00U, 0x0DU, 0xFFU, 0x57U, 0xD7U, 0x5DU, 0xF5U, 0xD0U, 0x03U, 0xF6U, - 0xE4U, 0x65U, 0x17U, 0x1BU, 0x48U, 0xCAU, 0x6DU, 0x4FU, 0xC6U, 0x10U, 0xB4U}; - -const uint8_t EMPTY_SHORT_LC[] = - {0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U}; - -const uint8_t DMR_SYNC = 0x5FU; CDMRDMOTX::CDMRDMOTX() : m_fifo(), @@ -53,18 +41,12 @@ void CDMRDMOTX::process() m_poLen = m_txDelay; } else { m_delay = false; - - createCACH(m_poBuffer + 0U, 0U); - for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) - m_poBuffer[i + 3U] = m_fifo.get(); - - createCACH(m_poBuffer + 36U, 1U); + for (unsigned int i = 0U; i < 72U; i++) + m_poBuffer[m_poLen++] = 0x00U; for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) - m_poBuffer[i + 39U] = m_idle[i]; - - m_poLen = 72U; + m_poBuffer[i] = m_fifo.get(); } m_poPtr = 0U; @@ -76,7 +58,7 @@ void CDMRDMOTX::process() while (space > 8U) { if (m_delay) { m_poPtr++; - writeByte(DMR_SYNC); + writeByte(0U); } else writeByte(m_poBuffer[m_poPtr++]); @@ -132,45 +114,3 @@ void CDMRDMOTX::setTXDelay(uint8_t delay) { m_txDelay = 600U + uint16_t(delay) * 12U; // 500ms + tx delay } - - -void CDMRDMOTX::createCACH(uint8_t* buffer, uint8_t slotIndex) -{ - if (m_cachPtr >= 12U) - m_cachPtr = 0U; - - ::memcpy(buffer, EMPTY_SHORT_LC + m_cachPtr, 3U); - - bool at = true; - bool tc = slotIndex == 1U; - bool ls0 = true; // For 1 and 2 - bool ls1 = true; - - if (m_cachPtr == 0U) // For 0 - ls1 = false; - else if (m_cachPtr == 9U) // For 3 - ls0 = false; - - bool h0 = at ^ tc ^ ls1; - bool h1 = tc ^ ls1 ^ ls0; - bool h2 = at ^ tc ^ ls0; - - buffer[0U] |= at ? 0x80U : 0x00U; - buffer[0U] |= tc ? 0x08U : 0x00U; - buffer[1U] |= ls1 ? 0x80U : 0x00U; - buffer[1U] |= ls0 ? 0x08U : 0x00U; - buffer[1U] |= h0 ? 0x02U : 0x00U; - buffer[2U] |= h1 ? 0x20U : 0x00U; - buffer[2U] |= h2 ? 0x02U : 0x00U; - - m_cachPtr += 3U; -} - -void CDMRDMOTX::setColorCode(uint8_t colorCode) -{ - ::memcpy(m_idle, IDLE_DATA, DMR_FRAME_LENGTH_BYTES); - - CDMRSlotType slotType; - slotType.encode(colorCode, DT_IDLE, m_idle); -} - diff --git a/DMRDMOTX.h b/DMRDMOTX.h index d4e3ef7..ce8459a 100644 --- a/DMRDMOTX.h +++ b/DMRDMOTX.h @@ -36,8 +36,6 @@ public: void setTXDelay(uint8_t delay); uint16_t getSpace() const; - - void setColorCode(uint8_t colorCode); private: CSerialRB m_fifo; @@ -47,10 +45,7 @@ private: uint16_t m_txDelay; uint32_t m_count; bool m_delay; - uint8_t m_idle[DMR_FRAME_LENGTH_BYTES]; - uint8_t m_cachPtr; - void createCACH(uint8_t* buffer, uint8_t slotIndex); void writeByte(uint8_t c); }; diff --git a/Makefile b/Makefile index fbab264..a2b2d06 100644 --- a/Makefile +++ b/Makefile @@ -53,17 +53,17 @@ else DFU_RST=./STM32F10X_Lib/utils/linux64/upload-reset DFU_UTIL=./STM32F10X_Lib/utils/linux64/dfu-util ST_FLASH=./STM32F10X_Lib/utils/linux64/st-flash - STM32FLASH=./STM32F10X_Lib/utils/linux64/stm32flash + STM32FLASH=./STM32F10X_Lib/utils/linux64/stm32flash else ifeq ($(shell uname -m),armv7l) DFU_RST=./STM32F10X_Lib/utils/rpi32/upload-reset DFU_UTIL=./STM32F10X_Lib/utils/rpi32/dfu-util ST_FLASH=./STM32F10X_Lib/utils/rpi32/st-flash - STM32FLASH=./STM32F10X_Lib/utils/rpi32/stm32flash + STM32FLASH=./STM32F10X_Lib/utils/rpi32/stm32flash else DFU_RST=./STM32F10X_Lib/utils/linux/upload-reset DFU_UTIL=./STM32F10X_Lib/utils/linux/dfu-util ST_FLASH=./STM32F10X_Lib/utils/linux/st-flash - STM32FLASH=./STM32F10X_Lib/utils/linux/stm32flash + STM32FLASH=./STM32F10X_Lib/utils/linux/stm32flash endif endif @@ -71,7 +71,7 @@ else DFU_RST=./STM32F10X_Lib/utils/macosx/upload-reset DFU_UTIL=./STM32F10X_Lib/utils/macosx/dfu-util ST_FLASH=./STM32F10X_Lib/utils/macosx/st-flash - STM32FLASH=./STM32F10X_Lib/utils/macosx/stm32flash + STM32FLASH=./STM32F10X_Lib/utils/macosx/stm32flash endif endif @@ -181,6 +181,15 @@ serial: serial-bl: $(STM32FLASH) -v -w STM32F10X_Lib/utils/bootloader/generic_boot20_pc13.bin -g 0x0 $(devser) $(STM32FLASH) -v -w bin/$(BINBIN) -g 0x0 -S 0x08002000 $(devser) + +zumspot-pi: +ifneq ($(wildcard /usr/local/bin/stm32flash),) + /usr/local/bin/stm32flash -v -w bin/$(BINBIN) -g 0x0 -R -i 20,-21,21:-20,21 /dev/ttyAMA0 +endif + +ifneq ($(wildcard /usr/bin/stm32flash),) + /usr/bin/stm32flash -v -w bin/$(BINBIN) -g 0x0 -R -i 20,-21,21:-20,21 /dev/ttyAMA0 +endif dfu: ifdef devser diff --git a/SerialPort.cpp b/SerialPort.cpp index 3f370c1..8a33f19 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -236,7 +236,6 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length) dmrDMOTX.setTXDelay(txDelay); dmrDMORX.setColorCode(colorCode); - dmrDMOTX.setColorCode(colorCode); io.setLoDevYSF(ysfLoDev);