Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit caa56d4

Browse files
cparatafpistm
authored andcommitted
Add DFU
Signed-off-by: Carlo.Parata <carlo.parata@st.com>
1 parent 3f1c091 commit caa56d4

File tree

5 files changed

+25
-29
lines changed

5 files changed

+25
-29
lines changed

boards.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
menu.upload_method=Upload method
3-
42
##############################################################
53
star_otto.name=Arduino Star OTTO
64

@@ -12,7 +10,7 @@ star_otto.upload.protocol=dfuse
1210

1311
star_otto.upload.use_1200bps_touch=true
1412
star_otto.upload.file_type=bin
15-
star_otto.upload.ram.maximum_size=262144
13+
star_otto.upload.ram.maximum_size=323584
1614
star_otto.upload.flash.maximum_size=2097152
1715
star_otto.upload.maximum_size=2097152
1816
star_otto.upload.mem_start=0x08000000
@@ -34,11 +32,4 @@ star_otto.build.cmsis_lib_gcc=arm_cortexM4l_math
3432
#To enable CDC add also '-DUSBD_USE_CDC'
3533
star_otto.build.extra_flags=-DSTM32F469xx -DUSE_USB_FS -DUSBCON -DUSBD_USE_CDC {build.usb_flags} -DESP_CH_UART -DESP_CH_UART_BR={build.esp_ch_uart_br}
3634

37-
star_otto.menu.upload_method.dfuMethod=arduinoSTM32load
38-
star_otto.menu.upload_method.dfuMethod.upload.protocol=dfuse
39-
star_otto.menu.upload_method.dfuMethod.upload.tool=arduinoSTM32load
40-
41-
star_otto.menu.upload_method.STLinkMethod=STLink
42-
star_otto.menu.upload_method.STLinkMethod.upload.protocol=STLink
43-
star_otto.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
4435
##############################################################

cores/arduino/stm32/usbd_cdc_if.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,9 @@ uint8_t lineSetup[] = {0x00, 0xc2, 0x01, 0x00, 0x00, 0x00, 0x08};
111111

112112
TIM_HandleTypeDef TimHandle;
113113

114-
#ifdef USE_DFU
115114
volatile uint8_t dfu_request = 0;
116115
/* For a bug in some Linux 64 bit PC we need to delay the reset of the CPU of 500ms seconds */
117116
int counter_dfu_reset = 500; /* the unit is equal to CDC_POLLING_INTERVAL that is 5ms by default */
118-
#endif // USE_DFU
119117

120118
static void TIM_Config(void);
121119

@@ -239,11 +237,9 @@ static int8_t CDC_Control_FS (uint8_t cmd, uint8_t* pbuf, uint16_t length)
239237
/*******************************************************************************/
240238
case CDC_SET_LINE_CODING:
241239
memcpy(lineSetup, pbuf, 7);
242-
#ifdef USE_DFU
243240
if(*((uint32_t*)pbuf) == 1200){
244241
dfu_request = 1;
245242
}
246-
#endif // USE_DFU
247243
break;
248244

249245
case CDC_GET_LINE_CODING:
@@ -386,7 +382,6 @@ void HAL_TIM6_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
386382
{
387383
uint8_t status;
388384

389-
#ifdef USE_DFU
390385
if(dfu_request) {
391386
counter_dfu_reset--;
392387
if(counter_dfu_reset == 0) {
@@ -396,7 +391,6 @@ void HAL_TIM6_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
396391
NVIC_SystemReset();
397392
}
398393
}
399-
#endif // USE_DFU
400394
if(USB_received) {
401395
USB_received = 0;
402396

platform.txt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build
9898
recipe.size.regex=^(?:\.text|\.rodata|\.ARM.exidx)\s+([0-9]+).*
9999
recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
100100

101+
#
102+
# DFU Util
103+
# --------
104+
105+
#tools.dfu-util.path={runtime.tools.dfu-util-0.9.0-arduino1.path}
106+
#tools.dfu-util.cmd=dfu-util
107+
#tools.dfu-util.cmd.windows=dfu-util.cmd
108+
109+
#tools.dfu-util.upload.params.verbose=-v
110+
#tools.dfu-util.upload.params.quiet=
111+
#tools.dfu-util.upload.pattern="{path}/{cmd}" "{path}" {upload.usbID} {upload.altID} {upload.mem_start} "{build.path}/{build.project_name}.bin" "{serial.port}"
112+
101113
#
102114
# arduinoSTM32load
103115
# ----------------
@@ -107,15 +119,4 @@ tools.arduinoSTM32load.upload.params.verbose=-v
107119
tools.arduinoSTM32load.upload.params.quiet=
108120
tools.arduinoSTM32load.upload.pattern="{path}/{cmd}" -dfu "{runtime.tools.dfu-util-0.9.0-arduino1.path}" -bin "{build.path}/{build.project_name}.bin" -port="{serial.port}" "{upload.params.verbose}"
109121

110-
tools.arduinoSTM32load.upload.network_pattern="{runtime.tools.wifilink_mcuota-1.0.0.path}/wifilink_mcuota" -f "{build.path}/{build.project_name}.hex" -i "{serial.port}"
111-
112-
# stlink upload
113-
tools.stlink_upload.cmd=stlink_upload
114-
tools.stlink_upload.cmd.windows=stlink_upload.bat
115-
tools.stlink_upload.path.windows={runtime.hardware.path}/tools/win
116-
tools.stlink_upload.path.macosx={runtime.hardware.path}/tools/macosx
117-
tools.stlink_upload.path.linux={runtime.hardware.path}/tools/linux
118-
tools.stlink_upload.path.linux64={runtime.hardware.path}/tools/linux64
119-
tools.stlink_upload.upload.params.verbose=-d
120-
tools.stlink_upload.upload.params.quiet=
121-
tools.stlink_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"
122+
#tools.arduinoSTM32load.upload.network_pattern="{runtime.tools.wifilink_mcuota-1.0.0.path}/wifilink_mcuota" -f "{build.path}/{build.project_name}.hex" -i "{serial.port}"

system/STM32F4xx/system_stm32f4xx.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
#define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
7575
#endif /* HSI_VALUE */
7676

77+
void enterSysROM(void);
78+
7779
/**
7880
* @}
7981
*/
@@ -167,6 +169,14 @@ const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
167169
*/
168170
void SystemInit(void)
169171
{
172+
/* Check if we are coming from a DFU enter request (see usbd_cdc_if.c)
173+
* This MUST be done before any other board configuration
174+
*/
175+
if(*((unsigned int*)0x2004FFF0) == 0xb311a21a) {
176+
*((unsigned int*)0x2004FFF0) = 0;
177+
enterSysROM();
178+
}
179+
170180
/* FPU settings ------------------------------------------------------------*/
171181
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
172182
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */

variants/otto/ldscript.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ _Min_Stack_Size = 0x400;; /* required amount of stack */
4343
MEMORY
4444
{
4545
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
46-
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
46+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 319K
4747
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
4848
}
4949

0 commit comments

Comments
 (0)