...
 
Commits (7)
......@@ -29,7 +29,8 @@ pipeline {
"px4fmuv4pro_bl",
"px4fmuv5_bl",
"px4io_bl",
"smartap_pro_bl"
"smartap_pro_bl",
"modalai_fc1_bl"
],
image: docker_images.nuttx,
archive: true
......
......@@ -74,7 +74,8 @@ TARGETS = \
px4io_bl \
px4iov3_bl \
tapv1_bl \
smartap_pro_bl
smartap_pro_bl \
modalai_fc_v1_bl
all: $(TARGETS) sizes
......@@ -144,6 +145,9 @@ avx_v1_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
smartap_pro_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=SMARTAP_PRO LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=[email protected]
modalai_fc_v1_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=MODALAI_FC_V1 LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=[email protected]
# Default bootloader delay is *very* short, just long enough to catch
# the board for recovery but not so long as to make restarting after a
# brownout problematic.
......
......@@ -42,13 +42,7 @@
#include <inttypes.h>
#include <stdlib.h>
# include <libopencm3/stm32/rcc.h>
# include <libopencm3/stm32/gpio.h>
# include <libopencm3/stm32/flash.h>
#include <libopencm3/cm3/scb.h>
#include <libopencm3/cm3/systick.h>
#include <stdbool.h>
#include "bl.h"
#include "cdcacm.h"
......@@ -148,7 +142,7 @@
#define STATE_ALLOWS_REBOOT (STATE_PROTO_GET_SYNC)
# define SET_BL_STATE(s)
#else
#define STATE_ALLOWS_ERASE (STATE_PROTO_GET_SYNC|STATE_PROTO_GET_DEVICE|STATE_PROTO_GET_CHIP)
#define STATE_ALLOWS_ERASE (STATE_PROTO_GET_SYNC|STATE_PROTO_GET_DEVICE)
#define STATE_ALLOWS_REBOOT (STATE_ALLOWS_ERASE|STATE_PROTO_PROG_MULTI|STATE_PROTO_GET_CRC)
# define SET_BL_STATE(s) bl_state |= (s)
#endif
......@@ -161,7 +155,7 @@ inline void cinit(void *config, uint8_t interface)
#if INTERFACE_USB
if (interface == USB) {
return usb_cinit();
return usb_cinit(config);
}
#endif
......@@ -231,7 +225,30 @@ inline void cout(uint8_t *buf, unsigned len)
#endif
}
/* The PX4IO is so low on FLASH that this abstaction is not possible as
* a called API. Therefore these macros are needed.
*/
#if defined(TARGET_HW_PX4_PIO_V1)
# include <libopencm3/stm32/flash.h>
#include <libopencm3/cm3/systick.h>
#include <libopencm3/cm3/scb.h>
#define arch_systic_init(d) \
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB); \
systick_set_reload(board_info.systick_mhz * 1000); \
systick_interrupt_enable(); \
systick_counter_enable();
#define arch_systic_deinit() \
systick_interrupt_disable(); \
systick_counter_disable();
#define arch_flash_lock flash_lock
#define arch_flash_unlock flash_unlock
#define arch_setvtor(address) SCB_VTOR = address;
#endif
static const uint32_t bl_proto_rev = BL_PROTOCOL_VERSION; // value returned by PROTO_DEVICE_BL_REV
......@@ -304,11 +321,10 @@ jump_to_app()
}
/* just for paranoia's sake */
flash_lock();
arch_flash_lock();
/* kill the systick interrupt */
systick_interrupt_disable();
systick_counter_disable();
arch_systic_deinit();
/* deinitialise the interface */
cfini();
......@@ -320,7 +336,7 @@ jump_to_app()
board_deinit();
/* switch exception handlers to the application */
SCB_VTOR = APP_LOAD_ADDRESS;
arch_setvtor(APP_LOAD_ADDRESS);
/* extract the stack and entrypoint from the app vector table and go */
do_jump(app_base[0], app_base[1]);
......@@ -523,10 +539,7 @@ bootloader(unsigned timeout)
uint32_t first_word = 0xffffffff;
/* (re)start the timer system */
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB);
systick_set_reload(board_info.systick_mhz * 1000); /* 1ms tick, magic number */
systick_interrupt_enable();
systick_counter_enable();
arch_systic_init();
/* if we are working with a timeout, start it running */
if (timeout) {
......@@ -663,7 +676,7 @@ bootloader(unsigned timeout)
led_set(LED_ON);
// erase all sectors
flash_unlock();
arch_flash_unlock();
for (int i = 0; flash_func_sector_size(i) != 0; i++) {
flash_func_erase_sector(i);
......@@ -709,7 +722,7 @@ bootloader(unsigned timeout)
goto cmd_bad;
}
if (arg > sizeof(flash_buffer.c)) {
if ((unsigned int)arg > sizeof(flash_buffer.c)) {
goto cmd_bad;
}
......
......@@ -110,6 +110,11 @@ extern void flash_func_write_word(uint32_t address, uint32_t word);
extern uint32_t flash_func_read_word(uint32_t address);
extern uint32_t flash_func_read_otp(uint32_t address);
extern uint32_t flash_func_read_sn(uint32_t address);
extern void arch_flash_lock(void);
extern void arch_flash_unlock(void);
extern void arch_setvtor(uint32_t address);
void arch_systic_init(void);
void arch_systic_deinit(void);
extern uint32_t get_mcu_id(void);
int get_mcu_desc(int max, uint8_t *revstr);
......
......@@ -26,6 +26,11 @@ TARGET_HW_CUBE_F4 9
TARGET_HW_AV_V1 29
TARGET_HW_KAKUTEF7 123
TARGET_HW_SMARTAP_PRO 32
TARGET_HW_MODALAI_FC_V1 41775
Reserved PX4 [BL] FMU v5X.x 51
Reserved "PX4 [BL] FMU v6.x" 52
Reserved "PX4 [BL] FMU v6X.x" 53
# values from external vendors
EXT_HW_RADIOLINK_MINI_PIX 3
......
......@@ -40,7 +40,7 @@
#pragma once
extern void usb_cinit(void);
extern void usb_cinit(void *pconfig);
extern void usb_cfini(void);
extern int usb_cin(void);
extern void usb_cout(uint8_t *buf, unsigned len);
......@@ -1047,6 +1047,47 @@
# define BOARD_LED_ON gpio_set
# define BOARD_LED_OFF gpio_clear
/****************************************************************************
* TARGET_HW_MODALAI_FC_V1
****************************************************************************/
#elif defined(TARGET_HW_MODALAI_FC_V1)
# define APP_LOAD_ADDRESS 0x08008000
# define BOOTLOADER_DELAY 5000
# define INTERFACE_USB 1
# define INTERFACE_USART 1
# define USBDEVICESTRING "PX4 BL ModalAI FCv1"
# define USBMFGSTRING "ModalAI"
# define USBPRODUCTID 0xa32f
# define USBVENDORID 0x0483
# define BOOT_DELAY_ADDRESS 0x000001a0
# define BOARD_TYPE 41775
# define _FLASH_KBYTES (*(uint16_t *)0x1ff0f442)
# define BOARD_FLASH_SECTORS ((_FLASH_KBYTES == 0x400) ? 7 : 11)
# define BOARD_FLASH_SIZE (_FLASH_KBYTES * 1024)
# define OSC_FREQ 16
# define BOARD_PIN_LED_ACTIVITY GPIO0 // RED
# define BOARD_PIN_LED_BOOTLOADER GPIO1 // GREEN
# define BOARD_PORT_LEDS GPIOB
# define BOARD_CLOCK_LEDS RCC_AHB1ENR_GPIOBEN
# define BOARD_LED_ON gpio_clear
# define BOARD_LED_OFF gpio_set
# define BOARD_USART USART3
# define BOARD_USART_CLOCK_REGISTER RCC_APB1ENR
# define BOARD_USART_CLOCK_BIT RCC_APB1ENR_USART3EN
# define BOARD_PORT_USART GPIOD
# define BOARD_PORT_USART_AF GPIO_AF7
# define BOARD_PIN_TX GPIO8
# define BOARD_PIN_RX GPIO9
# define BOARD_USART_PIN_CLOCK_REGISTER RCC_AHB1ENR
# define BOARD_USART_PIN_CLOCK_BIT RCC_AHB1ENR_GPIODEN
# define SERIAL_BREAK_DETECT_DISABLED 1
#else
# error Undefined Target Hardware
......
......@@ -11,6 +11,7 @@
#include <libopencm3/stm32/flash.h>
#include <libopencm3/stm32/usart.h>
#include <libopencm3/stm32/pwr.h>
#include <libopencm3/cm3/scb.h>
#include <libopencm3/cm3/systick.h>
#include "bl.h"
......@@ -153,6 +154,22 @@ clock_init(void)
rcc_clock_setup_hsi(&_rcc_hsi_8mhz);
}
inline void arch_systic_init(void)
{
/* (re)start the timer system */
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB);
systick_set_reload(board_info.systick_mhz * 1000); /* 1ms tick, magic number */
systick_interrupt_enable();
systick_counter_enable();
}
inline void arch_systic_deinit(void)
{
/* kill the systick interrupt */
systick_interrupt_disable();
systick_counter_disable();
}
/**
* @brief Resets the RCC clock configuration to the default reset state.
* @note The default reset state of the clock configuration is given below:
......@@ -187,6 +204,21 @@ clock_deinit(void)
RCC_CIR = 0x000000;
}
inline void arch_flash_lock(void)
{
flash_lock();
}
inline void arch_flash_unlock(void)
{
flash_unlock();
}
inline void arch_setvtor(uint32_t address)
{
SCB_VTOR = address;
}
/*---------------------------------------------------------------------------*/
/** @brief Program a Half Word to FLASH
......
......@@ -12,7 +12,9 @@
#include <libopencm3/stm32/usart.h>
#include <libopencm3/cm3/systick.h>
#include <libopencm3/stm32/pwr.h>
# include <libopencm3/stm32/timer.h>
#include <libopencm3/stm32/timer.h>
#include <libopencm3/cm3/scb.h>
#include <libopencm3/cm3/systick.h>
#include "bl.h"
#include "uart.h"
......@@ -485,6 +487,22 @@ clock_init(void)
rcc_clock_setup_hse_3v3(&clock_setup);
}
inline void arch_systic_init(void)
{
/* (re)start the timer system */
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB);
systick_set_reload(board_info.systick_mhz * 1000); /* 1ms tick, magic number */
systick_interrupt_enable();
systick_counter_enable();
}
inline void arch_systic_deinit(void)
{
/* kill the systick interrupt */
systick_interrupt_disable();
systick_counter_disable();
}
/**
* @brief Resets the RCC clock configuration to the default reset state.
* @note The default reset state of the clock configuration is given below:
......@@ -522,6 +540,21 @@ clock_deinit(void)
RCC_CIR = 0x000000;
}
inline void arch_flash_lock(void)
{
flash_lock();
}
inline void arch_flash_unlock(void)
{
flash_unlock();
}
inline void arch_setvtor(uint32_t address)
{
SCB_VTOR = address;
}
uint32_t
flash_func_sector_size(unsigned sector)
{
......
......@@ -13,6 +13,8 @@
#include <libopencm3/stm32/usart.h>
#include <libopencm3/cm3/systick.h>
#include <libopencm3/stm32/pwr.h>
#include <libopencm3/cm3/scb.h>
#include <libopencm3/cm3/systick.h>
#include "bl.h"
#include "uart.h"
......@@ -462,6 +464,22 @@ board_deinit(void)
RCC_AHB1ENR = 0x00100000; // XXX Magic reset number from STM32F4x reference manual
}
inline void arch_systic_init(void)
{
/* (re)start the timer system */
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB);
systick_set_reload(board_info.systick_mhz * 1000); /* 1ms tick, magic number */
systick_interrupt_enable();
systick_counter_enable();
}
inline void arch_systic_deinit(void)
{
/* kill the systick interrupt */
systick_interrupt_disable();
systick_counter_disable();
}
/**
* @brief Initializes the RCC clock configuration.
*
......@@ -510,6 +528,21 @@ clock_deinit(void)
RCC_CIR = 0x000000;
}
inline void arch_flash_lock(void)
{
flash_lock();
}
inline void arch_flash_unlock(void)
{
flash_unlock();
}
inline void arch_setvtor(uint32_t address)
{
SCB_VTOR = address;
}
uint32_t
flash_func_sector_size(unsigned sector)
{
......
......@@ -61,6 +61,10 @@
# define BOARD_INTERFACE_CONFIG_USB NULL
#endif
#define STK_CSR_CLKSOURCE_LSB 2
#define STK_CSR_CLKSOURCE_AHB_DIV8 (0 << STK_CSR_CLKSOURCE_LSB)
#define STK_CSR_CLKSOURCE_AHB (1 << STK_CSR_CLKSOURCE_LSB)
flash_config_t s_flashDriver; //!< Flash driver instance.
static uint32_t s_flashRunCommand[kFLASH_ExecuteInRamFunctionMaxSizeInWords];
static uint32_t s_flashCacheClearCommand[kFLASH_ExecuteInRamFunctionMaxSizeInWords];
......@@ -458,6 +462,22 @@ static void CLOCK_CONFIG_FllStableDelay(void)
}
}
inline void arch_systic_init(void)
{
/* (re)start the timer system */
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB);
systick_set_reload(board_info.systick_mhz * 1000); /* 1ms tick, magic number */
systick_interrupt_enable();
systick_counter_enable();
}
inline void arch_systic_deinit(void)
{
/* kill the systick interrupt */
systick_interrupt_disable();
systick_counter_disable();
}
void
clock_deinit(void)
{
......@@ -550,8 +570,17 @@ clock_deinit(void)
SystemCoreClock = BOARD_RESETCLOCKRUN_CORE_CLOCK;
}
void flash_lock(void)
inline void arch_flash_lock(void)
{
}
inline void arch_flash_unlock(void)
{
}
inline void arch_setvtor(uint32_t address)
{
SCB->VTOR = address;
}
uint32_t flash_func_sector_size(unsigned sector)
......
......@@ -301,7 +301,7 @@ otg_fs_isr(void)
}
void
usb_cinit(void)
usb_cinit(void *pconfig)
{
#if defined(STM32F4)
......