mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-11-09 16:41:21 +08:00
HAL_ChibiOS: save more space in the bootloader
This commit is contained in:
1 parent
e870b5f00a
commit
369ac5edd0
6 files changed
+80
-7
No files matched your search
@@ -28,12 +28,21 @@
|
||||
|
||||
#include <hwdef.h>
|
||||
|
||||
#ifndef HAL_NO_UARTDRIVER
|
||||
static HAL_UARTA_DRIVER;
|
||||
static HAL_UARTB_DRIVER;
|
||||
static HAL_UARTC_DRIVER;
|
||||
static HAL_UARTD_DRIVER;
|
||||
static HAL_UARTE_DRIVER;
|
||||
static HAL_UARTF_DRIVER;
|
||||
#else
|
||||
static Empty::UARTDriver uartADriver;
|
||||
static Empty::UARTDriver uartBDriver;
|
||||
static Empty::UARTDriver uartCDriver;
|
||||
static Empty::UARTDriver uartDDriver;
|
||||
static Empty::UARTDriver uartEDriver;
|
||||
static Empty::UARTDriver uartFDriver;
|
||||
#endif
|
||||
|
||||
#if HAL_USE_I2C == TRUE
|
||||
static ChibiOS::I2CDeviceManager i2cDeviceManager;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
#include <AP_HAL/AP_HAL.h>
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS && !defined(HAL_NO_UARTDRIVER)
|
||||
#include "UARTDriver.h"
|
||||
#include "GPIO.h"
|
||||
#include <usbcfg.h>
|
||||
|
||||
@@ -119,7 +119,9 @@
|
||||
* function becomes the idle thread and must implement an
|
||||
* infinite loop.
|
||||
*/
|
||||
#ifndef CH_CFG_NO_IDLE_THREAD
|
||||
#define CH_CFG_NO_IDLE_THREAD FALSE
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -166,7 +168,9 @@
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#ifndef CH_CFG_USE_REGISTRY
|
||||
#define CH_CFG_USE_REGISTRY TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Threads synchronization APIs.
|
||||
@@ -250,7 +254,9 @@
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#ifndef CH_CFG_USE_EVENTS
|
||||
#define CH_CFG_USE_EVENTS TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Events Flags APIs with timeout.
|
||||
@@ -260,7 +266,9 @@
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_CFG_USE_EVENTS.
|
||||
*/
|
||||
#ifndef CH_CFG_USE_EVENTS_TIMEOUT
|
||||
#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Synchronous Messages APIs.
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
|
||||
#define MIN_ALIGNMENT 8
|
||||
|
||||
#ifdef HAL_NO_CCM
|
||||
#undef CCM_RAM_SIZE_KB
|
||||
#endif
|
||||
|
||||
#if defined(CCM_RAM_SIZE_KB)
|
||||
static memory_heap_t ccm_heap;
|
||||
static bool ccm_heap_initialised = false;
|
||||
|
||||
@@ -33,10 +33,11 @@
|
||||
|
||||
int vsnprintf(char *str, size_t size, const char *fmt, va_list ap)
|
||||
{
|
||||
int retval = 0;
|
||||
#ifndef HAL_NO_PRINTF
|
||||
MemoryStream ms;
|
||||
BaseSequentialStream *chp;
|
||||
size_t size_wo_nul;
|
||||
int retval;
|
||||
|
||||
if (size > 0)
|
||||
size_wo_nul = size - 1;
|
||||
@@ -58,11 +59,13 @@ int vsnprintf(char *str, size_t size, const char *fmt, va_list ap)
|
||||
str[ms.eos] = 0;
|
||||
|
||||
/* Return number of bytes that would have been written.*/
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
int snprintf(char *str, size_t size, const char *fmt, ...)
|
||||
{
|
||||
#ifndef HAL_NO_PRINTF
|
||||
va_list arg;
|
||||
int done;
|
||||
|
||||
@@ -71,10 +74,14 @@ int snprintf(char *str, size_t size, const char *fmt, ...)
|
||||
va_end (arg);
|
||||
|
||||
return done;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int vasprintf(char **strp, const char *fmt, va_list ap)
|
||||
{
|
||||
#ifndef HAL_NO_PRINTF
|
||||
int len = vsnprintf(NULL, 0, fmt, ap);
|
||||
if (len <= 0) {
|
||||
return -1;
|
||||
@@ -86,15 +93,22 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
|
||||
vsnprintf(buf, len+1, fmt, ap);
|
||||
(*strp) = buf;
|
||||
return len;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int asprintf(char **strp, const char *fmt, ...)
|
||||
{
|
||||
#ifndef HAL_NO_PRINTF
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int ret = vasprintf(strp, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int vprintf(const char *fmt, va_list arg)
|
||||
@@ -112,6 +126,7 @@ int (*vprintf_console_hook)(const char *fmt, va_list arg) = vprintf;
|
||||
|
||||
int printf(const char *fmt, ...)
|
||||
{
|
||||
#ifndef HAL_NO_PRINTF
|
||||
va_list arg;
|
||||
int done;
|
||||
|
||||
@@ -120,6 +135,9 @@ int printf(const char *fmt, ...)
|
||||
va_end (arg);
|
||||
|
||||
return done;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
//just a stub
|
||||
|
||||
@@ -442,7 +442,26 @@ def write_mcu_config(f):
|
||||
#define HAL_BOOTLOADER_BUILD TRUE
|
||||
#define HAL_USE_ADC FALSE
|
||||
#define HAL_USE_EXT FALSE
|
||||
#define HAL_NO_UARTDRIVER
|
||||
#define HAL_NO_PRINTF
|
||||
#define HAL_NO_CCM
|
||||
#define CH_DBG_STATISTICS FALSE
|
||||
#define SERIAL_ADVANCED_BUFFERING_SUPPORT FALSE
|
||||
#define CH_CFG_USE_TM FALSE
|
||||
#define CH_CFG_USE_REGISTRY FALSE
|
||||
#define CH_CFG_USE_WAITEXIT FALSE
|
||||
#define CH_CFG_USE_DYNAMIC FALSE
|
||||
#define CH_CFG_USE_MEMPOOLS FALSE
|
||||
#define CH_DBG_FILL_THREADS FALSE
|
||||
#define CH_CFG_USE_SEMAPHORES TRUE
|
||||
#define CH_CFG_USE_MUTEXES FALSE
|
||||
#define CH_CFG_USE_CONDVARS FALSE
|
||||
#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE
|
||||
#define CH_CFG_USE_EVENTS_TIMEOUT FALSE
|
||||
#define CH_CFG_USE_MESSAGES FALSE
|
||||
#define CH_CFG_USE_MAILBOXES FALSE
|
||||
#define HAL_USE_I2C FALSE
|
||||
#define HAL_USE_PWM FALSE
|
||||
''')
|
||||
|
||||
def write_ldscript(fname):
|
||||
@@ -626,9 +645,22 @@ def write_UART_config(f):
|
||||
f.write("STM32_%s_RX_DMA_CONFIG, STM32_%s_TX_DMA_CONFIG, %s}\n" %
|
||||
(dev, dev, rts_line))
|
||||
f.write('#define HAL_UART_DEVICE_LIST %s\n\n' % ','.join(devlist))
|
||||
if not need_uart_driver:
|
||||
if not need_uart_driver and not args.bootloader:
|
||||
f.write('#define HAL_USE_SERIAL FALSE\n')
|
||||
|
||||
def write_UART_config_bootloader(f):
|
||||
'''write UART config defines'''
|
||||
get_config('UART_ORDER')
|
||||
uart_list = config['UART_ORDER']
|
||||
f.write('\n// UART configuration\n')
|
||||
devlist = []
|
||||
for u in uart_list:
|
||||
if u.startswith('OTG'):
|
||||
devlist.append('(BaseChannel *)&SDU1')
|
||||
else:
|
||||
unum = int(u[-1])
|
||||
devlist.append('(BaseChannel *)&SD%u' % unum)
|
||||
f.write('#define BOOTLOADER_DEV_LIST %s\n' % ','.join(devlist))
|
||||
|
||||
def write_I2C_config(f):
|
||||
'''write I2C config defines'''
|
||||
@@ -978,10 +1010,12 @@ def write_hwdef_header(outfilename):
|
||||
dma_priority=get_config('DMA_PRIORITY',default='TIM* SPI*', spaces=True),
|
||||
dma_noshare=get_config('DMA_NOSHARE',default='', spaces=True))
|
||||
|
||||
write_PWM_config(f)
|
||||
|
||||
write_I2C_config(f)
|
||||
write_UART_config(f)
|
||||
if not args.bootloader:
|
||||
write_PWM_config(f)
|
||||
write_I2C_config(f)
|
||||
write_UART_config(f)
|
||||
else:
|
||||
write_UART_config_bootloader(f)
|
||||
|
||||
if len(romfs) > 0:
|
||||
f.write('#define HAL_HAVE_AP_ROMFS_EMBEDDED_H 1\n')
|
||||
|
||||
Reference in new issue
Block a user