Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.

Ou/gcc compile #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "boot_conf.h"
#include "mks_conf.h"

#include "stm32f1xx_hal.h"
#include "stm32f1xx_hal_conf.h"
#include "stm32f1xx_hal_spi.h"
#include "stm32f1xx_hal_tim.h"
#include "boot_conf.h"
#include "fatfs.h"

#if defined(STM32F107xC) && defined(MKS_TFT)
Expand Down Expand Up @@ -65,11 +69,6 @@ void Error_Handler(void);
static void MX_GPIO_Init(void);
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);

void osDelay(__IO uint32_t Delay)
{
HAL_Delay(Delay);
}

inline void moveVectorTable(uint32_t Offset)
{
// __disable_irq();
Expand Down
3 changes: 3 additions & 0 deletions Inc/Buzzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef BUZZER_H_
#define BUZZER_H_

#include "mks_conf.h"
#include "stm32f1xx_hal_tim.h"

#ifdef __cplusplus

namespace Buzzer
Expand Down
1 change: 1 addition & 0 deletions Inc/PanelDue.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "RequestTimer.h"
#include "PrinterStatus.h"
#include "UserInterface.h"
#include "eeprom.h"

// Functions called from the serial I/O module
extern void ProcessReceivedValue(const char id[], const char val[], int index);
Expand Down
3 changes: 3 additions & 0 deletions Inc/bsp_driver_sd.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@
#ifndef __STM32F1XX_SD_H
#define __STM32F1XX_SD_H


#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"
#include "stm32f1xx_hal_conf.h"
#include "stm32f1xx_hal_sd.h"

/* Exported constants --------------------------------------------------------*/

Expand Down
1 change: 1 addition & 0 deletions Inc/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define __EEPROM_H

#include "stm32f1xx_hal.h"
#include "stm32f1xx_hal_i2c.h"
#include "cmsis_os.h"

#define EEPROM_ADDRESS 0xA0 // A0 = A1 = A2 = 0
Expand Down
2 changes: 2 additions & 0 deletions Inc/mks_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@

#include "ecv.h"
#include "stm32f1xx_hal.h"
#include "stm32f1xx_hal_spi.h"
#include "cmsis_os.h"
#include "fatfs.h"


#if defined(STM32F107xC) && defined(MKS_TFT)
/**
* Makerbase MKS-TFT32
Expand Down
144 changes: 144 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
TARGET=main.hex
EXECUTABLE=main.elf
BINARY=main.bin

CC=arm-none-eabi-gcc
LD=arm-none-eabi-gcc
AR=arm-none-eabi-ar
AS=arm-none-eabi-as
CP=arm-none-eabi-objcopy
OD=arm-none-eabi-objdump

BIN=$(CP) -O ihex

DEFS = -D__HEAP_SIZE=0x200 -D__STACK_SIZE=0x100 -DSTM32F107VC -DSTM32F10X_CL -DSTM32F107xC -DMKS_TFT -DILI9328 -MMD
STARTUP = Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f107xc.s

MCU = cortex-m3
MCFLAGS = -mcpu=$(MCU) -mthumb

STM32_INCLUDES = -IDrivers/STM32F1xx_HAL_Driver/Inc/ \
-IDrivers/CMSIS/Device/ST/STM32F1xx/Include/ \
-IDrivers/CMSIS/Include/ \
-IIcons \
-IInc \
-IBootloader \
-IMiddlewares/Third_Party/FreeRTOS/Source/include \
-IMiddlewares/Third_Party/FatFs/src/ \
-IMiddlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc \
-IMiddlewares/ST/STM32_USB_Host_Library/Core/Inc \
-IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3 \
-IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS

OPTIMIZE = -Os

CFLAGS = $(MCFLAGS) $(OPTIMIZE) $(DEFS) -fno-exceptions -funroll-loops -fdata-sections -ffunction-sections -g3 $(STM32_INCLUDES) -Wl,-T,STM32F107VC_FLASH.ld
AFLAGS = $(MCFLAGS)

SRC = Src/main.c \
Src/stm32f1xx_hal_msp.c \
Src/stm32f1xx_hal_timebase_TIM.c \
Src/stm32f1xx_it.c \
Src/usb_host.c \
Src/usbh_conf.c \
Src/usbh_diskio.c \
Src/fatfs.c \
Src/spiflash_w25q16dv.c \
Src/spisd_diskio.c \
Src/Buzzer.cpp \
Src/PanelDue.cpp \
Src/Display.cpp \
Src/FileManager.cpp \
Src/SerialIo.cpp \
Src/UserInterface.cpp \
Src/UTFT.cpp \
Src/UTouch.cpp \
Src/eeprom.c \
Src/Mem.cpp \
Src/MessageLog.cpp \
Src/Print.cpp \
Src/Misc.cpp \
Src/RequestTimer.cpp

#SRC += Bootloader/flash.c \
#Bootloader/main.c \
#Bootloader/stm32f1xx_it.c \

SRC += Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_hcd.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \
Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c
#Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_sd.c \
#Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_fsmc.c \
#Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_sdmmc.c \
#Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_sram.c \

SRC += Fonts/glcd17x22.cpp \
Icons/HomeIcons.cpp \
Icons/KeyIcons.cpp \
Icons/MiscIcons.cpp \
Icons/NozzleIcons.cpp
#Fonts/glcd28x32.cpp \

SRC += Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c \
Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_bot.c \
Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_scsi.c \
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c \
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c \
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c \
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c \
Middlewares/Third_Party/FatFs/src/diskio.c \
Middlewares/Third_Party/FatFs/src/ff.c \
Middlewares/Third_Party/FatFs/src/ff_gen_drv.c \
Middlewares/Third_Party/FatFs/src/option/ccsbcs.c \
Middlewares/Third_Party/FatFs/src/option/syscall.c \
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c \
Middlewares/Third_Party/FreeRTOS/Source/croutine.c \
Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \
Middlewares/Third_Party/FreeRTOS/Source/list.c \
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c \
Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c \
Middlewares/Third_Party/FreeRTOS/Source/queue.c \
Middlewares/Third_Party/FreeRTOS/Source/tasks.c \
Middlewares/Third_Party/FreeRTOS/Source/timers.c \

OBJDIR = build
OBJ = $(SRC:%.c=$(OBJDIR)/%.o)
OBJ += Startup.o

all: $(BINARY)

$(BINARY): $(EXECUTABLE)
$(CP) -O binary $(EXECUTABLE) $(BINARY)

flash: $(BINARY)
st-flash write $(BINARY) 0x08000000
# stm32flash -w $(BINARY) -v -g 0x0 /dev/ttyUSB0

$(EXECUTABLE): $(SRC) $(STARTUP)
$(CC) $(CFLAGS) $^ -lm -lstdc++ -lgcc -lc -lnosys -o $@

clean:
echo rm -f Startup.lst $(TARGET) $(TARGET).lst $(AUTOGEN) $(TARGET).out $(TARGET).hex $(TARGET).map \
$(TARGET).dmp $(EXECUTABLE)
# $(OBJ)

# Последнюю строчку лучше добавить в make, в секцию executable:
# $(EXECUTABLE): $(SRC) $(STARTUP)
# $(CC) $(CFLAGS) $^ -lm -lc -lnosys -o $@
# $(CP) -O binary $(EXECUTABLE).elf $(EXECUTABLE).bin
2 changes: 1 addition & 1 deletion Src/Buzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* The backlight control is included in this module because it also uses PWM. Output PWMH1 (aka PB1 peripheral A) drives the backlight pin.
*/

#include "Buzzer.h"
#include <cstring>

#include "ecv.h"
#include "stm32f1xx_hal.h"
#include "cmsis_os.h"

#include "Buzzer.h"

TimerHandle_t xBuzzerTimer;
extern TIM_HandleTypeDef htim2;
Expand Down
2 changes: 1 addition & 1 deletion Src/Mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* Author: David
*/

#include "Mem.h"
#include "ecv.h"
#include "stm32f1xx_hal.h"
#include "cmsis_os.h"
#include "Mem.h"

//#include <new>
//void* operator new(size_t objsize, std::nothrow_t dummy) {
Expand Down
2 changes: 1 addition & 1 deletion Src/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "ecv.h"
#include "Misc.h"

#include <cstring>
//#include <cstring>
#include <cstdlib>

// Safe version of strncpy that ensures that the destination is always null-terminated on return
Expand Down
2 changes: 1 addition & 1 deletion Src/bsp_driver_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "bsp_driver_sd.h"

/* Extern variables ---------------------------------------------------------*/

extern SD_HandleTypeDef hsd;
extern HAL_SD_CardInfoTypedef SDCardInfo;

Expand Down
2 changes: 1 addition & 1 deletion Src/fatfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
******************************************************************************
*/

#include "fatfs.h"
#include "mks_conf.h"
#include "fatfs.h"

#if defined(STM32F107xC) && defined(MKS_TFT)
char SPISD_Path[4]; /* USER logical drive path */
Expand Down
6 changes: 3 additions & 3 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"
#include "cmsis_os.h"
#include "fatfs.h"

#include "stm32f1xx_hal_i2c.h"
#include "stm32f1xx_hal_uart.h"
#include "mks_conf.h"
#include "cmsis_os.h"

#if defined(STM32F107xC) && defined(MKS_TFT)
# include "usb_host.h"
Expand Down