AP_HAL_ChibiOS: add SD card support to bootloader
This commit is contained in:
parent
fbc9da904c
commit
48639c6810
@ -14,6 +14,15 @@
|
||||
*
|
||||
* Code by Andrew Tridgell and Siddharth Bharat Purohit
|
||||
*/
|
||||
|
||||
#include <AP_HAL/AP_HAL_Boards.h>
|
||||
|
||||
#ifndef HAL_SCHEDULER_ENABLED
|
||||
#define HAL_SCHEDULER_ENABLED 1
|
||||
#endif
|
||||
|
||||
#if HAL_SCHEDULER_ENABLED
|
||||
|
||||
#include <AP_HAL/AP_HAL.h>
|
||||
|
||||
#include <hal.h>
|
||||
@ -788,5 +797,6 @@ void Scheduler::check_stack_free(void)
|
||||
}
|
||||
#endif // CH_DBG_ENABLE_STACK_CHECK == TRUE
|
||||
|
||||
|
||||
#endif // CH_CFG_USE_DYNAMIC
|
||||
|
||||
#endif // HAL_SCHEDULER_ENABLED
|
||||
|
@ -1109,7 +1109,9 @@ def write_mcu_config(f):
|
||||
#define HAL_USE_I2C FALSE
|
||||
#define HAL_USE_PWM FALSE
|
||||
#define HAL_NO_UARTDRIVER
|
||||
#ifndef CH_CFG_USE_DYNAMIC
|
||||
#define CH_CFG_USE_DYNAMIC FALSE
|
||||
#endif
|
||||
#define HAL_USE_EMPTY_STORAGE 1
|
||||
#ifndef HAL_STORAGE_SIZE
|
||||
#define HAL_STORAGE_SIZE 16384
|
||||
@ -1136,11 +1138,19 @@ def write_mcu_config(f):
|
||||
#endif
|
||||
#define HAL_NO_ROMFS_SUPPORT TRUE
|
||||
#define CH_CFG_USE_TM FALSE
|
||||
#ifndef CH_CFG_USE_REGISTRY
|
||||
#define CH_CFG_USE_REGISTRY FALSE
|
||||
#endif
|
||||
#ifndef CH_CFG_USE_WAITEXIT
|
||||
#define CH_CFG_USE_WAITEXIT FALSE
|
||||
#endif
|
||||
#ifndef CH_CFG_USE_MEMPOOLS
|
||||
#define CH_CFG_USE_MEMPOOLS FALSE
|
||||
#endif
|
||||
#define CH_DBG_FILL_THREADS FALSE
|
||||
#ifndef CH_CFG_USE_MUTEXES
|
||||
#define CH_CFG_USE_MUTEXES FALSE
|
||||
#endif
|
||||
#define CH_CFG_USE_EVENTS FALSE
|
||||
#define CH_CFG_USE_EVENTS_TIMEOUT FALSE
|
||||
#define HAL_USE_EMPTY_STORAGE 1
|
||||
@ -1149,14 +1159,22 @@ def write_mcu_config(f):
|
||||
#endif
|
||||
#define HAL_USE_RTC FALSE
|
||||
#define DISABLE_SERIAL_ESC_COMM TRUE
|
||||
#ifndef CH_CFG_USE_DYNAMIC
|
||||
#define CH_CFG_USE_DYNAMIC FALSE
|
||||
#endif
|
||||
#define DISABLE_WATCHDOG 1
|
||||
''')
|
||||
if not env_vars['EXT_FLASH_SIZE_MB'] and not args.signed_fw:
|
||||
f.write('''
|
||||
#ifndef CH_CFG_USE_MEMCORE
|
||||
#define CH_CFG_USE_MEMCORE FALSE
|
||||
#endif
|
||||
#ifndef CH_CFG_USE_SEMAPHORES
|
||||
#define CH_CFG_USE_SEMAPHORES FALSE
|
||||
#endif
|
||||
#ifndef CH_CFG_USE_HEAP
|
||||
#define CH_CFG_USE_HEAP FALSE
|
||||
#endif
|
||||
''')
|
||||
if env_vars.get('ROMFS_UNCOMPRESSED', False):
|
||||
f.write('#define HAL_ROMFS_UNCOMPRESSED\n')
|
||||
@ -3014,6 +3032,8 @@ def add_bootloader_defaults(f):
|
||||
// AP_Bootloader defaults
|
||||
|
||||
#define HAL_DSHOT_ALARM_ENABLED 0
|
||||
#define HAL_LOGGING_ENABLED 0
|
||||
#define HAL_SCHEDULER_ENABLED 0
|
||||
|
||||
// bootloaders *definitely* don't use the FFT library:
|
||||
#ifndef HAL_GYROFFT_ENABLED
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <hal.h>
|
||||
#include "SPIDevice.h"
|
||||
#include "sdcard.h"
|
||||
#include "bouncebuffer.h"
|
||||
#include "hwdef/common/spi_hook.h"
|
||||
#include <AP_BoardConfig/AP_BoardConfig.h>
|
||||
#include <AP_Filesystem/AP_Filesystem.h>
|
||||
@ -26,9 +27,11 @@ extern const AP_HAL::HAL& hal;
|
||||
|
||||
#ifdef USE_POSIX
|
||||
static FATFS SDC_FS; // FATFS object
|
||||
static bool sdcard_running;
|
||||
#ifndef HAL_BOOTLOADER_BUILD
|
||||
static HAL_Semaphore sem;
|
||||
#endif
|
||||
static bool sdcard_running;
|
||||
#endif
|
||||
|
||||
#if HAL_USE_SDC
|
||||
static SDCConfig sdcconfig = {
|
||||
@ -52,9 +55,13 @@ static SPIConfig highspeed;
|
||||
bool sdcard_init()
|
||||
{
|
||||
#ifdef USE_POSIX
|
||||
#ifndef HAL_BOOTLOADER_BUILD
|
||||
WITH_SEMAPHORE(sem);
|
||||
|
||||
uint8_t sd_slowdown = AP_BoardConfig::get_sdcard_slowdown();
|
||||
#else
|
||||
uint8_t sd_slowdown = 0; // maybe take from a define?
|
||||
#endif
|
||||
#if HAL_USE_SDC
|
||||
|
||||
#if STM32_SDC_USE_SDMMC2 == TRUE
|
||||
@ -134,7 +141,7 @@ bool sdcard_init()
|
||||
}
|
||||
#endif
|
||||
sdcard_running = false;
|
||||
#endif
|
||||
#endif // USE_POSIX
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool sdcard_init();
|
||||
void sdcard_stop();
|
||||
bool sdcard_retry();
|
||||
|
Loading…
Reference in New Issue
Block a user