Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to fix flash and other related bugs #11

Merged
merged 8 commits into from
May 21, 2019
Merged
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
24 changes: 12 additions & 12 deletions STM32F103RCTx_FLASH.ld
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ _estack = 0x2000C000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */

_Reserved_Space = 0x800;
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K - _Reserved_Space
RESERVED_FLASH (rw) : ORIGIN = 0x8000000 + 256K - _Reserved_Space, LENGTH = _Reserved_Space
}

/* Define output sections */
Expand Down Expand Up @@ -82,15 +83,6 @@ SECTIONS
. = ALIGN(4);
} >FLASH

/* create a section in flash which is aligned on a page boundary, don't really care where. */
.myFlashSection :
{
. = ALIGN(2048);
*(.myFlashSection)
*(.myFlashSection*)
. = ALIGN(2048);
} >FLASH

.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
Expand Down Expand Up @@ -118,6 +110,15 @@ SECTIONS
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH

/* create a section in flash which is aligned on a page boundary, don't really care where. */
.myFlashSection :
{
. = ALIGN(2048);
*(.myFlashSection)
. = ALIGN(2048);
} >RESERVED_FLASH


/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
Expand Down Expand Up @@ -175,4 +176,3 @@ SECTIONS
.ARM.attributes 0 : { *(.ARM.attributes) }
}


12 changes: 6 additions & 6 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build_flags =
-I${PROJECT_DIR}/src/hbprotocol/
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-T${PROJECT_DIR}/STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
# -Wl,-lnosys
Expand All @@ -42,7 +42,7 @@ build_flags =
-I${PROJECT_DIR}/src/hbprotocol/
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-T${PROJECT_DIR}/STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
-Og
Expand Down Expand Up @@ -117,7 +117,7 @@ build_flags =
-I${PROJECT_DIR}/src/hbprotocol/
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-T${PROJECT_DIR}/STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
-Og
Expand Down Expand Up @@ -184,7 +184,7 @@ build_flags =
-I${PROJECT_DIR}/src/hbprotocol/
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-T${PROJECT_DIR}/STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
-Og
Expand Down Expand Up @@ -247,7 +247,7 @@ build_flags =
-I${PROJECT_DIR}/src/hbprotocol/
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-T${PROJECT_DIR}/STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
-Og
Expand Down Expand Up @@ -295,4 +295,4 @@ build_flags =
-D STEER_COEFFICIENT=0.5 ; higher value == stronger. if you do not want any steering, set it to 0.0; 0.0 to 1.0
-D INVERT_R_DIRECTION
-D INVERT_L_DIRECTION
-D BEEPS_BACKWARD=0 ; 0 or 1
-D BEEPS_BACKWARD=0 ; 0 or 1
4 changes: 2 additions & 2 deletions src/comms.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void consoleLog(char *message)
USART2_IT_send((unsigned char *)message, strlen(message));
#elif defined(SERIAL_USART3_IT) && !defined(READ_SENSOR)
USART3_IT_send((unsigned char *)message, strlen(message));
#else
#elif !defined(READ_SENSOR)
HAL_UART_Transmit_DMA(&huart2, (uint8_t *)message, strlen(message));
#endif
#endif
Expand Down Expand Up @@ -231,4 +231,4 @@ SERIAL_USART_IT_BUFFERTYPE serial_usart_buffer_pop(volatile SERIAL_USART_BUFFER
usart_buf->tail = ((usart_buf->tail + 1 ) % SERIAL_USART_BUFFER_SIZE);
}
return t;
}
}
4 changes: 2 additions & 2 deletions src/flashaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//extern volatile const uint8_t flash_data[];

// last two pages of the first half
volatile uint8_t *flash_data = (uint8_t *) 0x08000000 + 62*2048;
volatile uint8_t *flash_data = (uint8_t *) 0x08000000 + 0x40000 - 0x800;
int flashlen = 4096; // two pages

// routines to read and write config data
Expand Down Expand Up @@ -230,4 +230,4 @@ int writeflashchunk( void *addr, unsigned char *data, int len ){
}


#endif
#endif
4 changes: 2 additions & 2 deletions src/flasharea.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "defines.h"
#include "config.h"

#ifdef FLASH_STORAGE
#ifdef FLASH_STORAGE_INIT
// this should reserve a single 2k flash block at 0x0800C000
// page = 30

Expand Down Expand Up @@ -150,4 +150,4 @@ const uint8_t __attribute__((section (".myFlashSection"))) flash_data_inimage[FL

};

#endif
#endif
7 changes: 3 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ int main(void) {
#ifdef SERIAL_USART3_IT
USART3_IT_init();
#endif
#ifdef SOFTWARE_SERIAL
SoftwareSerialInit();
#endif

#ifdef FLASH_STORAGE
init_flash_content();
Expand Down Expand Up @@ -336,10 +339,6 @@ int main(void) {
HallInterruptinit();
#endif

#ifdef SOFTWARE_SERIAL
SoftwareSerialInit();
#endif

#ifdef CONTROL_PPM
PPM_Init();
#endif
Expand Down