-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this prevents inclusion of abort() calls on some error paths common.h: added externs for telem data main: expanded eeprom to 184 bytes extra space for DroneCAN parameters added DroneCAN support l431: added RAM function support and flash_update this allows for update of application flash while application code is running DroneCAN: support firmwate update over CAN allows for update without changes to the bootloader added ArmingStatus messages DroneCAN: implement ArmingStatus don't spin motors unless armed DroneCAN: allow change of direction without reboot DroneCAN: added TELEM_RATE and REQUIRE_ARMING use #if DRONECAN_SUPPORT fixes for updated Makefile targets: added SierraPulse1 DroneCAN: added BI_DIRECTIONAL and ADVANCE_LEVEL DroneCAN: stop motor after 0.25s of no input DroneCAN: split out STM32 specific CAN code ready for supporting other MCUs rename ldscript helps with choosing ldscript_CAN.ld DroneCAN: removed fw update logic use CAN bootloader use CAN suffix to select CAN target build separate out CAN and non-CAN targets l431: don't override SCB->VTOR this is set correctly by the bootloader DroneCAN: setup backup registers for fwupdate DroneCAN: support application signature allows bootloader to confirm a good firmware fixed signature in debug.elf fix current value convert add motor kv and tune to dronecan params add HSE support and VIMDRONES_NANO_L431_CAN DroneCAN: prevent early CAN interrupts when canard not ready DroneCAN: all CAN targets will use 128k flash this matches the bootloader l431: cleanup clock setup code removed unused code l431: allow HSE_VALUE to be set in targets.h allows per target HSE DroneCAN: ensure at least 1kHz input seen from DroneCAN gives smooth operation at low CAN rates DroneCAN: average current over last period reduces noise DroneCAN: fixed changing BI_DIRECTION prevent bad motor start DroneCAN: added REQUIRE_ZERO_THROTTLE f415: rework flash code based on bootloader this allows support for AT-START-F415 for testing, and is less flash support F415 DroneCAN added TBS CAN F415 target DroneCAN: fixed F415 for PA11/PA12 targets: fixed TBS F415 targets targets: fixed NANO_431_CAN current scaling f415: fixed vector table address for DroneCAN rename TUNE to STARTUP_TUNE fix VIMDRONES_L431_CAN current sampling scale and add offset targets: fixed TBS F415 voltage DroneCAN: added optional acceleration filter 2 pole butterworth filter DroneCAN: fill in defaults and min/max DroneCAN: expose braking parameters DroneCAN: expose AUTO_ADVANCE setting DroneCAN: get default value from default_settings array DroneCAN: added DEBUG_RATE and improve setting of default values for all parameters DroneCAN: added FlexDebug message move inputType enum to common.h DroneCAN: added INPUT_SIGNAL_TYPE and ability to disable DShot interrupts DroneCAN: expose PWM frequency DroneCAN: added FlexDebug debug messages DroneCAN: fixed parameter load DroneCAN: fixed RPM calculation thanks Huibean! DroneCAN: added lua script for AM32 debug DroneCAN: send RX ecode DroneCAN: fixed F415 CAN build DroneCAN: fixed a bug with setting BI_DIRECTION while booted DroneCAN: fixes for new eeprom structure targets: fixed build of F415 TBS CAN board
- Loading branch information
Showing
141 changed files
with
14,207 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,60 @@ | ||
#include "eeprom.h" | ||
#include "targets.h" | ||
|
||
#include <string.h> | ||
#include <stdbool.h> | ||
|
||
//#pragma GCC optimize("O0") | ||
|
||
#include "at32f415_flash.h" | ||
|
||
// #define APP_START (uint32_t)0x08001000 | ||
// #define FLASH_STORAGE 0x08005000 // at the 31kb mark | ||
#define page_size 0x400 // 1 kb for f051 | ||
// uint32_t FLASH_FKEY1 =0x45670123; | ||
// uint32_t FLASH_FKEY2 =0xCDEF89AB; | ||
/* | ||
the F415 can be either 1k or 2k sector size. The 256k flash part has | ||
2k sector size. We only support ESCs with 128k flash or less, so 1k | ||
sector size, but it is useful to work with 2k sector size when using | ||
a F415 dev board like the AT-Start F415, so we detect here. | ||
*/ | ||
static inline uint32_t sector_size() | ||
{ | ||
const uint16_t *F_SIZE = (const uint16_t *)0x1FFFF7E0; | ||
if (*F_SIZE <= 128) { | ||
// 1k sectors for 128k flash or less | ||
return 1024; | ||
} | ||
// 256k flash is 2k sectors | ||
return 2048; | ||
} | ||
|
||
void save_flash_nolib(uint8_t* data, int length, uint32_t add) | ||
{ /// todo | ||
|
||
// fmc_wscnt_set(2); | ||
|
||
// fmc_prefetch_enable(); | ||
|
||
uint32_t data_to_FLASH[length / 4]; | ||
memset(data_to_FLASH, 0, length / 4); | ||
for (int i = 0; i < length / 4; i++) { | ||
data_to_FLASH[i] = data[i * 4 + 3] << 24 | data[i * 4 + 2] << 16 | data[i * 4 + 1] << 8 | data[i * 4]; // make 16 bit | ||
{ | ||
if ((add & 0x3) != 0 || (length & 0x3) != 0) { | ||
return; | ||
} | ||
volatile uint32_t data_length = length / 4; | ||
/* | ||
we need the data to be 32 bit aligned | ||
*/ | ||
const uint32_t word_length = length / 4; | ||
|
||
// unlock flash | ||
|
||
flash_unlock(); | ||
|
||
// erase page if address even divisable by 1024 | ||
if ((add % 1024) == 0) { | ||
flash_sector_erase(add); | ||
// erase page if address even divisable by sector size | ||
if ((add % sector_size()) == 0) { | ||
flash_sector_erase(add); | ||
} | ||
|
||
volatile uint32_t index = 0; | ||
while (index < data_length) { | ||
// fmc_word_program(add + (index*4),data_to_FLASH[index]); | ||
flash_word_program(add + (index * 4), data_to_FLASH[index]); | ||
// fmc_flag_clear(FMC_FLAG_END | | ||
// FMC_FLAG_WPERR | | ||
// FMC_FLAG_PGERR); | ||
flash_flag_clear(FLASH_PROGRAM_ERROR | FLASH_EPP_ERROR | FLASH_OPERATE_DONE); | ||
uint32_t index = 0; | ||
while (index < word_length) { | ||
uint32_t word; | ||
memcpy(&word, &data[index*4], sizeof(word)); | ||
flash_word_program(add + (index * 4), word); | ||
flash_flag_clear(FLASH_PROGRAM_ERROR | FLASH_EPP_ERROR | FLASH_OPERATE_DONE); | ||
index++; | ||
} | ||
flash_lock(); | ||
} | ||
|
||
void read_flash_bin(uint8_t* data, uint32_t add, int out_buff_len) | ||
{ | ||
// volatile uint32_t read_data; | ||
for (int i = 0; i < out_buff_len; i++) { | ||
data[i] = *(uint8_t*)(add + i); | ||
} | ||
} | ||
memcpy(data, (void*)add, out_buff_len); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.